I have an image width/height/stride and buffer.
How do I convert this information to a System.Drawing.Bitmap? Can I get the original image back if I have these 4 things?
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.
There is a
Bitmapconstructor overload, which requires everything you have (plusPixelFormat):public Bitmap(int width, int height, int stride, PixelFormat format, IntPtr scan0);This might work (if
args.Bufferis an array of blittable type, likebytefor example):Update:
Probably it’s better to copy image bytes to newly created
Bitmapmanually, because it seems like that constructors doesn’t do that, and ifbyte[]array of image data gets garbage collected all sorts of bad things can happen.