i know to "store" Image into Memo and also to "write" Image from Memo.
now i ask to "fill" a empty new Bitmap with String" from Memo.
---
normal i have to use IMAGE or PICTURE "at Create" to assign it from Resource
when "load" Image (from Disk) i got a hBitmap to "PAINT"
Question : how to get Handle of Image (String) from Memo

i need to create a Bitmap ... but i want it "in Memory"
this is what i do under Xbase++ using Ot4Xb.
how under harbour HMG

Code: Select all
// CreateCompatibleDC()
nHdcCompat := @Gdi32:CreateCompatibleDC(hDC)
// load Image "String" from memo
cBuf := Picture->Memo
// Create a blank OS-level bitmap with the required dimensions
nHandleBmp := @GDI32:CreateDIBSection(0,cBuf,DIB_RGB_COLORS,0,0,0)
IF nHandleBmp == 0
RETURN 0
ENDIF
// see function
cData := GetWindowsImageData( cBuf )
// SetDIBits()
nTmp := @GDI32:SetDIBits( 0 ,;
nHandleBmp ,;
0 ,;
oBitmap:YSize ,;
cData ,;
cBuf ,;
DIB_RGB_COLORS )
// SelectObject()
hOldBmpMem := @Gdi32:SelectObject( nHdcCompat, nHandleBmp )
// BitBlt()
nRet := @Gdi32:BitBlt( hDC ,; // "paint" into DC
...
Code: Select all
FUNCTION GetWindowsImageData( cBuf )
LOCAL nOffset := SIZEOF_BITMAPINFOHEADER
LOCAL nColors
DO CASE
CASE ::Bits == 16
CASE ::Bits == 24
CASE ::Bits == 32
OTHERWISE
// Bit count is 4 or 8
nColors := Bin2U( SubStr(cBuf, 33, 4) ) // (biClrsUsed)
IF nColors == 0
nColors := Int(2 ^ ::Bits)
ENDIF
nOffset += nColors * SIZEOF_RGBQUAD
ENDCASE
RETURN SubStr(cBuf, nOffset +1)