Convert image to byte array
-
Hi, I need some help to convert an image to byte array and byte array to image. Can any one help? :)
-
Hi, I need some help to convert an image to byte array and byte array to image. Can any one help? :)
You can start with GetDIBits GDI API function. GetDIBits The GetDIBits function retrieves the bits of the specified compatible bitmap and copies them into a buffer as a DIB using the specified format. int GetDIBits( HDC hdc, // handle to DC HBITMAP hbmp, // handle to bitmap UINT uStartScan, // first scan line to set UINT cScanLines, // number of scan lines to copy LPVOID lpvBits, // array for bitmap bits LPBITMAPINFO lpbi, // bitmap data buffer UINT uUsage // RGB or palette index );
-
Hi, I need some help to convert an image to byte array and byte array to image. Can any one help? :)
Jose's reply is great for HBITMAPs. Just using the word "image" is extremely vague. It's a lot easier for us to help you if you're a bit more specific. What kind of image? What format is the image? etc... Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
Hi, I need some help to convert an image to byte array and byte array to image. Can any one help? :)
You don't need to: images are just a byte arrays. :rolleyes:
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Jose's reply is great for HBITMAPs. Just using the word "image" is extremely vague. It's a lot easier for us to help you if you're a bit more specific. What kind of image? What format is the image? etc... Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
Actually i am writing code to diaply image read by an imagescanner device. In this i need to support all formats of images. So, i need to display an image which is in byte array format. How to do that?
-
Actually i am writing code to diaply image read by an imagescanner device. In this i need to support all formats of images. So, i need to display an image which is in byte array format. How to do that?
hari_honey wrote:
i need to support all formats of images
All? That's pretty ambitious. Many image formats are published. You'll need to study the format specifications and read/write the byte streams accordingly. For BMP, GIF, JPEG, Exif, PNG, and TIFF, GDI+[^] can help. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
You can start with GetDIBits GDI API function. GetDIBits The GetDIBits function retrieves the bits of the specified compatible bitmap and copies them into a buffer as a DIB using the specified format. int GetDIBits( HDC hdc, // handle to DC HBITMAP hbmp, // handle to bitmap UINT uStartScan, // first scan line to set UINT cScanLines, // number of scan lines to copy LPVOID lpvBits, // array for bitmap bits LPBITMAPINFO lpbi, // bitmap data buffer UINT uUsage // RGB or palette index );
How to get the blob data from this function? where is the blob data found in it??