C# resize generated image; bitmap, argument exception -
i have image object i'm trying resize picture box via bitmap.
i have source picture box on desktop , code follows
bitmap image = new bitmap(picturebox1.image); size newsize = new size(100,100); image = new bitmap( (image)image, newsize); // here parameter not valid, argument exception unhandled picturebox1.image = (image)image;
why exception being thrown?
first of all, don't understand why create 2 bitmap objects? why not this:
bitmap image = (bitmap)picturebox1.image; size newsize = new size(100,100); bitmap newimage = new bitmap((image)image, newsize); image.dispose();
however don't think exception caused shown code. it's possible read above on screen :
newsize {width = 128000 height = 59500}
have calculated how big picture?
size x 4 bytes of format = 3.0464^ 10.
i don't think have enough memory allocate image.
Comments
Post a Comment