0
如何將WriteableBitmap的大小調整爲從2768x2768到1500x1500的位置?在C#中爲WindowsPhone 8調整WriteableBitmap的大小
我無法找到任何可擴展選件,以及其他所有的代碼不兼容爲W
謝謝!
如何將WriteableBitmap的大小調整爲從2768x2768到1500x1500的位置?在C#中爲WindowsPhone 8調整WriteableBitmap的大小
我無法找到任何可擴展選件,以及其他所有的代碼不兼容爲W
謝謝!
您可以使用下面的代碼
public byte[] ChangeDimension(BitmapImage bitmapImage, int width, int height)
{
byte[] data = null;
using (MemoryStream stream = new MemoryStream())
{
WriteableBitmap wBitmap = new WriteableBitmap(bitmapImage);
wBitmap.SaveJpeg(stream,width, height, 0, 100);
stream.Seek(0, SeekOrigin.Begin);
data = stream.GetBuffer();
}
return data;
}
安裝nuget包WriteableBitmapEx
(可寫入位圖擴展名)。
它提供了一個Resize()
擴展方法。
另一種選擇是PictureDecoder類,它允許加載縮放版本的圖像(如果它是JPEG)。
這些不工作,我仍然得到「圖片過大」的錯誤調整圖片的大小。我的OCR庫只允許2600x2600 pixelwdith/pixelheight,並且在使用此工具裁剪/調整大小後,我仍然收到錯誤消息。 – user2536897 2014-10-16 18:23:20
啊對,writeablebitmaps有一個大小限制,它是2000x2000 – thumbmunkeys 2014-10-16 18:26:39
那麼至少2600x2600。我用背部相機拍攝的圖像出來的是2000x2000,所以我想這很好。我需要將它們裁剪爲800x600 – user2536897 2014-10-16 20:42:18