如何保存“CroppedBitmap" [英] How to save a "CroppedBitmap"
本文介绍了如何保存“CroppedBitmap"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了一个裁剪的位图,现在我想保存它.我知道如何保存位图帧,但我不知道如何将其转换为位图帧.
I created a cropped Bitmap and now i want to save it. I know how to save a bitmapframe, but i dont know how to convert it to a bitmapframe.
代码:
' Create an Image element.
Dim croppedImage As New Image()
croppedImage.Width = 200
croppedImage.Margin = New Thickness(5)
' Create a CroppedBitmap based off of a xaml defined resource.
Dim cb As New CroppedBitmap(CType(screenshot, BitmapSource), New Int32Rect(X, Y, breite, höhe))
'select region rect
croppedImage.Source = cb 'set image source to cropped
所以我想将新图像另存为文件.
So I want to save the new Image as file.
推荐答案
我在 C# 中做了同样的事情,希望你能转换成 vb
Hi i did the same thing in C#, i hope you can convert into vb
void saveCroppedBitmap(CroppedBitmap image,string path)
{
FileStream mStream = new FileStream(path, FileMode.Create);
JpegBitmapEncoder jEncoder = new JpegBitmapEncoder();
jEncoder.Frames.Add(BitmapFrame.Create(image));
jEncoder.Save(mStream);
}
这篇关于如何保存“CroppedBitmap"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文