久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

調整位圖圖像的大小

Resize bitmap image(調整位圖圖像的大小)
本文介紹了調整位圖圖像的大小的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我想在保存圖像時使用更小的尺寸.我怎樣才能調整它的大小?我使用此代碼重新繪制圖像:

I want to have smaller size at image saved. How can I resize it? I use this code for redering the image:

Size size = new Size(surface.Width, surface.Height);
surface.Measure(size);
surface.Arrange(new Rect(size));
// Create a render bitmap and push the surface to it
RenderTargetBitmap renderBitmap =
    new RenderTargetBitmap(
        (int)size.Width,
        (int)size.Height, 96d, 96d,
        PixelFormats.Default);
renderBitmap.Render(surface);

BmpBitmapEncoder encoder = new BmpBitmapEncoder();
// push the rendered bitmap to it
encoder.Frames.Add(BitmapFrame.Create(renderBitmap));
// save the data to the stream
encoder.Save(outStream);

推薦答案

您的表面"視覺效果是否具有縮放功能?如果沒有,您可以將其包裝在 Viewbox 中,然后以您想要的大小渲染 Viewbox.

Does your "surface" visual have scaling capability? You can wrap it in a Viewbox if not, then render the Viewbox at the size you want.

當您在表面上調用測量和排列時,您應該提供您希望位圖的大小.

When you call Measure and Arrange on the surface, you should provide the size you want the bitmap to be.

要使用 Viewbox,請將您的代碼更改為如下所示:

To use the Viewbox, change your code to something like the following:

Viewbox viewbox = new Viewbox();
Size desiredSize = new Size(surface.Width / 2, surface.Height / 2);

viewbox.Child = surface;
viewbox.Measure(desiredSize);
viewbox.Arrange(new Rect(desiredSize));

RenderTargetBitmap renderBitmap =
    new RenderTargetBitmap(
    (int)desiredSize.Width,
    (int)desiredSize.Height, 96d, 96d,
    PixelFormats.Default);
renderBitmap.Render(viewbox);

這篇關于調整位圖圖像的大小的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Right-click on a Listbox in a Silverlight 4 app(右鍵單擊 Silverlight 4 應用程序中的列表框)
WPF c# webbrowser scrolls over top menu(WPF c# webbrowser 在頂部菜單上滾動)
C# Console app - How do I make an interactive menu?(C# 控制臺應用程序 - 如何制作交互式菜單?)
How to avoid duplicate form creation in .NET Windows Forms?(如何避免在 .NET Windows Forms 中創建重復的表單?)
UI Automation Control Desktop Application and Click on Menu Strip(UI自動化控制桌面應用程序并單擊菜單條)
Removing thin border around the menuitems(刪除菜單項周圍的細邊框)
主站蜘蛛池模板: 一级片视频免费 | 日本免费视频在线观看 | 成人一级黄色毛片 | 成人精品一区 | 在线成人免费视频 | 久久精品女人天堂av | 国产精品一区二 | 国产午夜三级一区二区三 | 超碰97免费 | 99成人| av天天看 | 久久久久久99 | 日本免费一区二区三区 | 97精品超碰一区二区三区 | 免费看a | 中文字幕av一区 | 日一区二区 | 欧美成人a| 亚洲色图插插插 | 久久久片 | 天天天操操操 | 中文字幕在线观看精品 | 久久99久久久久 | 精品免费国产视频 | 日韩精品在线一区 | 久久久久一区 | 日韩欧美视频 | 亚洲一区二区免费看 | 亚洲精品不卡 | 91极品欧美视频 | 做a视频 | 天天插天天操 | 国产免费一级一级 | 久久91av| 中文字幕不卡一区 | av网站在线播放 | 国产精品一区二区三区在线 | 男女网站免费 | 日韩欧美国产一区二区 | 欧美性生活网 | 欧美日在线|