Click here to Skip to main content
15,902,114 members
Please Sign up or sign in to vote.
1.44/5 (3 votes)
See more:
Hello Everyone.
i want to convert
C#
IntPtr
to
C#
Image
.

i have try this. but not given me a scan image.

C#
IntPtr img = (IntPtr) pics[ i ];
Bitmap _img = new Bitmap(2450, 2450, 2452, PixelFormat.Format32bppRgb, img)
pictureBox1.Image = _img;
Posted
Updated 6-Apr-19 17:34pm
Comments
Sergey Alexandrovich Kryukov 4-Dec-15 3:01am    
It's pretty apparent that you mean System.Drawing.Bitmap, but you need to provide full type name, to reduce confusion and greatly improve your chances of getting help.
—SA

Talking about "conversion" here is incorrect; and, more importantly, we don't know what is pics. Most likely, type casting to IntPtr would be impractical absurd; this type is used for passing pointers to unmanaged memory or object handles.

But in essence, I can imagine that you have some data structures describing the color (or color+alpha) for each pixel, and you need to put this data in a bitmap. Then the answer is pretty obvious: https://msdn.microsoft.com/en-us/library/system.drawing.bitmap.lockbits%28v=vs.110%29.aspx[^].

You will find a complete code sample on the MSDN help page on one of these similar methods.

—SA
 
Share this answer
 
System.Drawing.Image.FromHbitmap(IntPtr input)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900