I have used the following code to convert the image in a PictureBox into a Bitmap:
bmp = (Bitmap)pictureBox2.Image;
But I am getting the result as bmp = null. Can anyone tell me how I do this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Check this, it is working at my side.
/// Using BitMap Class
You can directly cast
pictureBox2.Imageto Bitmap as you are doing and also using the Bitmap class to convert to Bitmap class object.Ref: Bitmap Constructor (Image).