Search code examples
graphicsscalegdi+pixel

Extract pixels buffer from Image Gdi+


I would like to extract pixel buffer from Gdiplus::Image Here is my code :

Gdiplus::Bitmap bitmap(GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), BPP4 * GetSystemMetrics(SM_CXSCREEN), PixelFormat32bppARGB, data);

Gdiplus::Image *pThumbnail = bitmap.GetThumbnailImage(mWidthResolutionSelected, mHeightResolutionSelected, NULL, NULL);

How to get pixel buffer after the scale with GetThumbnailImage from pThumbnail ? Thanks


Solution

  • You cast pThumbnail to a Bitmap* and then you use the LockBits method to get a BitmapData object, which contains the Scan0 field, which is a pointer to the pixel data. Don't forget to call UnlockBits when you're done.