久久久久久久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(刪除菜單項周圍的細邊框)
主站蜘蛛池模板: 日韩欧美亚洲一区 | 精品国产女人 | 91精品导航 | 国产小视频精品 | 国产日韩欧美 | 91视频观看 | 国产真实精品久久二三区 | www.久久久.com | 午夜精品三区 | 久久99深爱久久99精品 | 日本午夜一区二区三区 | 日本黄色激情视频 | 国产成人精品一区二区三区 | 免费观看羞羞视频网站 | av在线一区二区三区 | 久久人人网 | 中文在线a在线 | 日本成人一区二区 | 男女一区二区三区 | 亚洲成人动漫在线观看 | 久久久久久久国产 | 天堂一区二区三区 | 在线不卡视频 | 久久精品国产久精国产 | 久久国产精品视频 | 中文字幕在线观看一区 | 性一交一乱一伦视频免费观看 | 亚洲色图插插插 | 欧美高清性xxxxhd | 成人影院午夜 | 九九热免费观看 | 久久久久久久97 | 亚洲日韩中文字幕 | 中文视频在线 | 亚洲美女网站 | 羞羞视频一区二区 | 91黄色片免费看 | 久久久久久九九九九 | 91精品久久久久久综合五月天 | 午夜视频在线 | 国产不卡在线 |