久久久久久久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(刪除菜單項周圍的細邊框)
主站蜘蛛池模板: 黄色三级大片 | a视频在线观看 | 成人精品免费视频 | 日本伊人久久 | 亚洲成人精品 | 亚洲影院av | 精品国产乱码久久久久 | 亚洲精品综合 | 国产无遮挡又黄又爽免费网站 | 日韩精品视频免费播放 | 欧美视频在线观看免费 | 亚洲精品免费看 | 草少妇 | 亚洲性生活片 | 日本成片网 | 日韩网站免费观看 | 久久性色 | www.一区二区 | 日本高清网站 | 欧美黄色一区 | 亚洲小视频 | 久久精品综合 | 欧美一区二区三区在线 | 成年人免费看片 | 日韩精品福利 | 欧美在线视频一区二区 | 黄色综合网 | 国产人成一区二区三区影院 | 国产一区二区精品在线 | 一区二区在线免费观看 | 玖玖色资源 | 欧美精产国品一二三区 | 国产理论在线 | 国产青青草 | 黄色一级大片 | 欧美一道本| 久久高清免费视频 | 欧美黄色片在线观看 | 国产精品视频久久久 | 九九视频免费观看 | 久久精品视频一区二区 |