C# resize generated image; bitmap, argument exception -


enter image description here

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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -