Gdiplus construct Image from line

I am extracting images from a MySQL database using the MySQL ++ API. I get images like mysqlpp :: sql_mediumblob representing a row. Now I want to rotate some images using GDI +, but I'm not sure how to use this constructor:

Image::Image(IStream*,BOOL) - Creates an Image object based on a stream.

with the image that is stored in blob. Thanks in advance.

+3
source share
1 answer

As noted here: http://msdn.microsoft.com/en-us/library/aa378980(VS.85).aspx

HGLOBAL hMem = ::GlobalAlloc(GMEM_MOVEABLE,iSize);
if (!hMem)
    AfxThrowMemoryException();
LPVOID pImage = ::GlobalLock(hMem);
... // Fill memory pointed by pImage, reading it from MySQL
::GlobalUnlock(hMem);

// Convert internal data if there is any
CComPtr<IStream> spStream;
HRESULT hr = ::CreateStreamOnHGlobal(hMem,FALSE,&spStream);

Then pass spStream to the Gdiplus :: Image constructor.

+1
source

Source: https://habr.com/ru/post/1704880/


All Articles