I am reading in a bitmap that is quite large and has a lot of useless space. The original image height is 2048 and the width is 1024.
I want to crop/clip the image for display purposes starting from the bottom left and showing an image height of 1047 and width of 1024 in c#. I've tried using CroppedBitmap but I keep getting an out of bounds error.
(The code below shows some random parameters as I started inputting a lot of stuff to get it to work even a little.)
This gives me the error:
CroppedBitmap cb = new CroppedBitmap((BitmapSource)bitmapImage,
new Int32Rect(2048,0,30,50));
EDIT: To put it another way, I want to get rid of the top half of the image.
CroppedBitmap cb = new CroppedBitmap(
bitmapImage,
new Int32Rect(0, (int)(bitmapImage.Height/2),
(int)bitmapImage.Width, (int)(bitmapImage.Height/2));
This will create a CroppedBitmap from the lower half of the bitmapImage. The Int32Rect should describe the part you want to keep.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.