Page 1 of 1

Tranparent bitmap

Posted: Fri Nov 13, 2009 2:25 pm
by Gary Woodley
Hi,

I am using a modified PaintTranparent function as below to create a bitmap in a window. Is there any way I can use centering rather than recalculate the x and y co-ordinates? Then I will only have _ the image, assuming thats possible.

Code: Select all

FUNCTION PaintTransparent( hDC, hBitmap, nRow, nCol )
   LOCAL hBmpOld := SelectObject( hDC, hBitmap )
   LOCAL nZeroZeroClr := GetPixel( hDC, 0, 0 )
   LOCAL nOldClr
      
   DEFAULT nRow:= 375
   DEFAULT nCol:= 250

   SelectObject( hDC, hBmpOld )
   nOldClr = SetBkColor( hDC, CLR_WHITE )
   TransBmp( hBitmap, nBmpWidth( hBitmap ), nBmpHeight( hBitmap ), nZeroZeroClr, hDC, nRow, nCol, nBmpWidth( hBitmap ), nBmpHeight( hBitmap ) )
   SetBkColor( hDC, nOldClr ) 
               
RETURN NIL
 
Thanks

Gary

Re: Tranparent bitmap

Posted: Fri Nov 13, 2009 4:01 pm
by ukoenig
The way I center a Image :

Image

FUNCTION W_ALPHA( hDC )
LOCAL oBmp1

nWidth := GetSysMetrics(0)
nHeight := GetSysMetrics(1)
DEFINE BITMAP oBMP1 FILENAME c_path + "\IMAGES\Deco1.BMP"
nTop := ( nHeight / 2 ) - ( oBmp1:nHeight / 2 )
nLeft := (nWidth / 2 ) - ( oBmp1:nWidth / 2 )
ABPaint( hDC, nLeft, nTop, oBmp1:hBitmap, 220 )

RETURN NIL

Best Regards
Uwe :lol: