Page 1 of 1

refill a bitmap

Posted: Sun Jan 17, 2010 8:36 pm
by MdaSolution
If I have a bitmap showed on a dialog

sample
Image


can I refill only the black arrow with a different color ( RED, BLU,YELLOW) ?

I wish that the arrow must be refilled by end user with the mouse

How I can make this ?

Re: refill a bitmap

Posted: Sun Jan 17, 2010 9:13 pm
by ukoenig
It must be the same BMP ( size ) but with a red Arrow. A BMP for each color.
You can replace the BMP with the black Arrow with the one with the red Arrow.

// from File
// REDEFINE BITMAP oBmp1 ID 100 OF oDlg FILENAME Black.bmp"

// from resource
REDEFINE BITMAP oBMP1 ID 100 ADJUST RESOURCE "Black" OF oDlg
oBMP1:bPainted := {|hDC| ReplaceBMP ( oBMP1, newBMP1 ) }

A oBMP1:Refresh() will replace the BMP with newBMP1
( can be a Button-action or Mouse-focus )

// Replace BMP on MouseClick

REDEFINE BITMAP oBMP1 ID 100 ADJUST RESOURCE "Black" OF oDlg ;
ON CLICK ReplaceBMP ( oBMP1, "Red.bmp" )

// ------------ Replace ------------

FUNCTION ReplaceBMP( oBitmap, cBitmap)
Local oImage

DEFINE IMAGE oImage FILENAME cBitmap
aRect := GETCLIENTRECT( oBitmap:hWnd )

PalBmpDraw( oBitmap:GETDC(), 0, 0, oImage:hBitmap, , aRect[4], aRect[3] )
oBitmap:ReleaseDC()

RETURN( NIL )


Best Regards
Uwe :lol:

Re: refill a bitmap

Posted: Sun Jan 17, 2010 10:44 pm
by MdaSolution
sorry But I found the function FloodFill

I think it can be done calculating the coors the bitmaps

FloodFill(hCDC, x,y , CLR_BLACK, nColor)

but I not Know How Found the coors of the bitmap