Tranparent bitmap

Post Reply
Gary Woodley
Posts: 28
Joined: Mon Apr 27, 2009 3:37 pm
Location: Oxford UK

Tranparent bitmap

Post 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
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: Tranparent bitmap

Post 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:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
Post Reply