I have a image in picturebox. I want to get that image as a Bitmap.
My one line code is:
Bitmap default_image = (Bitmap)pictureBox5.Image.Clone();
But what i am getting is:
default_image value=null;
Can anyone help me.
Bitmap default_image = new Bitmap(pictureBox5.Image);
You are never instantiating a Bitmap
which is why it is null
.
If you got the image into the PictureBox by using imageLocation
pbSourceImage.ImageLocation = openFile.FileName;
then PictureBox.Image will be null.
Instead, load the picture using
pbSourceImage.Image = Image.FromFile(openFile.FileName);
Then you will be able to clone from the Image property.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With