How to paint a transparent bitmap on a bitmap ?

How to paint a transparent bitmap on a bitmap ?

Postby RAMESHBABU » Sat Nov 25, 2006 5:04 pm

Hi

Can anybody suggest me how to paint a transparent bitmap on a bitmap
painted at a particular location of a non-brushed dialog ?

Code: Select all  Expand view  RUN
// Text on a bitmap

#include "FiveWin.ch"

FUNC main()

   local oWnd, oBmp, oBmp1

   DEFINE WINDOW oWnd TITLE "Text on a bitmap"

   @ 1, 1 BITMAP oBmp FILENAME "..\bitmaps\magic.bmp" OF oWnd

   oBmp:bPainted = { || SetBkMode( oBmp:hDC, 1 ),;
                        SetTextColor( oBmp:hDC, CLR_YELLOW ),;
                        TextOut( oBmp:hDC, 5, 5, "Hello" ) }

   @ 2, 1 BITMAP oBmp1 FILENAME "..\bitmaps\book.bmp" OF oBmp NO BORDER

   ACTIVATE WINDOW oWnd

RETURN NIL



The Result is :

Image

But I want the book's background should get merged with the image in the background of the lady in the picture.


Thanks

- Ramesh Babu P
User avatar
RAMESHBABU
 
Posts: 625
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

Postby Antonio Linares » Sat Nov 25, 2006 6:06 pm

Ramesh,
Code: Select all  Expand view  RUN
#include "FiveWin.ch"

FUNC main()

   local oWnd, oBmp, oBmp1, hBitmap

   DEFINE WINDOW oWnd TITLE "Text on a bitmap"

   hBitmap := ReadBitmap( 0, "..\bitmaps\book.bmp" )

   @ 1, 1 BITMAP oBmp FILENAME "..\bitmaps\magic.bmp" OF oWnd

   oBmp:bPainted = { || PaintTransparent( oBmp:hDC, hBitmap ),;
                        SetBkMode( oBmp:hDC, 1 ),;
                        SetTextColor( oBmp:hDC, CLR_YELLOW ),;
                        TextOut( oBmp:hDC, 5, 5, "Hello" ) }

   ACTIVATE WINDOW oWnd

   DeleteObject( hBitmap )

RETURN NIL

function PaintTransparent( hDC, hBitmap )

   local hBmpOld := SelectObject( hDC, hBitmap )
   local nZeroZeroClr := GetPixel( hDC, 0, 0 )
   local nOldClr

   SelectObject( hDC, hBmpOld )
   nOldClr = SetBkColor( hDC, nRGB( 255, 255, 255 ) )
   TransBmp( hBitmap, nBmpWidth( hBitmap ), nBmpHeight( hBitmap ),;
             nZeroZeroClr, hDC, 10, 20, nBmpWidth( hBitmap ), nBmpHeight( hBitmap ) )
   SetBkColor( hDC, nOldClr )         

return nil

Image
And change book.bmp this way:
Image
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42120
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby RAMESHBABU » Sun Nov 26, 2006 10:39 am

Hello Mr.Antonio

Thank you very much.

Your function "PaintTransparent( hDC, hBitmap )" has done the job.

Regards

- Ramesh Babu P
User avatar
RAMESHBABU
 
Posts: 625
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 54 guests