Re: Win32 Transparency

new topic     » goto parent     » topic index » view thread      » older message » newer message

Greg Harris wrote:

> Hi David,
>
> -----Original Message-----
> From: David Cuny <dcuny at LANSET.COM>
> Subject: Win32 Transparency
>
> >Does anyone know if there is a relatively easy way to display "transparent"
> >images in using the Win32 API? I've run across the 'image list' where you
> >store a bitmap and a mask, but it looks a bit klunky.
>
> No there isn't a relative easy way to do this in the Win32 API that I know
> of.
> I've used the above method with fair success.
>
> Reagrds,
>
> Greg Harris

of course there is... with gdi32.dll you can do all these stuff with masks....

You have to create first two CompatibleBitmaps (one for hold your source
bitpmaps and another to serve as stage where the screen is assembled and the
called to screen).

I have somewhere docs about the tecnique... I will find them...
For now stay with a sample of a program done in Lyberty Basic... it could be
easily trnslated for Euphoria...
I hope it helps anyway..


calldll #user ,"GetDC",_
hG as word,_ 'the handle of the graphic box
hDC as word 'the handle of the DC of the graphic box

calldll #gdi,"CreateCompatibleDC",_
hDC as word,_ 'the handle of the DC of the graphic box
hdcMEM as word 'the handle of the new DC we create

calldll #gdi,"CreateCompatibleDC",_
hDC as word,_ 'the handle of the DC of the graphic box
hdcSTAGE as word 'the handle of the DC we create

calldll #gdi,"CreateCompatibleBitmap",_
hDC as word,_ 'the handle of the DC of the graphic box
352 as word,_ 'width of new bitmap in memory
352 as word,_ 'height of new bitmap in memory
stage as word 'name we give our new bitmap in memory

calldll #gdi,"SelectObject",_
hdcSTAGE as word,_ 'DC in memory to hold bitmaps
stage as word,_ 'the name of the bitmap we place in this DC
result as word

calldll #gdi,"SelectObject",_
hdcMEM as word,_ 'DC in memory to hold bitmaps
hback as word,_ 'the name of the bitmap we place in this DC
r as word

[put.in.screen]

calldll #gdi,"BitBlt",_
hDC as word,_
0 as word,_
0 as word,_
352 as word, _
352 as word,_
hdcSTAGE as word, _
0 as word, _
0 as word,_
13369376  as long, _
r as ushort

'print #1.g, "getbmp bmpname 0 0 352 352"
'print #1.g, "drawbmp bmpname 0 0"
'print #1.g, "flush"

return


[drawinstage]

calldll #gdi,"SelectObject",_
hdcMEM as word,_ 'DC in memory to hold bitmaps
hback as word,_ 'the name of the bitmap we place in this DC
r as word

calldll #gdi,"BitBlt",_
hdcSTAGE as word,_ 'destination DC - copy image to here
xto as word,_ 'x location to place image
yto as word,_ 'y location to place image
width as word, _ 'width of image to transfer
height as word,_ 'height of image to transfer
hdcMEM as word, _ 'source DC - copy image from here
xfrom as word, _ 'x location to copy from
yfrom as word, _ 'y location to copy from
13369376 as long, _ 'SRCCOPY
r as ushort
return


[add.mask]

calldll #gdi,"SelectObject",_
hdcMEM as word,_ 'DC of memory
hmask as word,_ 'name of mask image
r as word

calldll #gdi,"BitBlt",_
hdcSTAGE as word,_ 'destination DC = memory staging area
xto as word,_ 'x location to place image
yto as word,_ 'y location to place image
width as word, _ 'width of image to transfer
height as word,_ 'height of image to transfer
hdcMEM as word, _ 'source DC = memory
xfrom as word, _ 'x location to copy image from
yfrom as word, _ 'y location to copy image from
8913094 as long, _ 'SRCAND
r as ushort
return


[add.sprite]

calldll #gdi,"SelectObject",_
hdcMEM as word,_ 'DC of memory
hobj as word,_ 'name of normal image
r as word

calldll #gdi,"BitBlt",_
hdcSTAGE as word,_ 'destination DC = memory staging area
xto as word,_ 'x location to place image
yto as word,_ 'y location to place image
width as word, _ 'width of image to transfer
height as word,_ 'height of image to transfer
hdcMEM as word, _ 'source DC = memory
xfrom as word, _ 'x location to copy image from
yfrom as word, _ 'y location to copy image from
15597702 as long,_ 'SRCPAINT
r as ushort
return

and now a piece of code to call that funtions.... it would print on screen a
masked bitmap with 32x32 pixels

x=2
y=9
xto=32*(x-1)
yto=32*(y-1)
xfrom=160
yfrom=224
widht=32
height=32
gosub [add.mask]
gosub [add.sprite]
gosub [put.in.screen]


--
N u n o  B a r r o s                      [ W e b   D e s i g n e r ]
----------------------------------------------------------------------
[ m a i l ] nuno.barros at ip.pt             [ i c q ]     6 4 4 8 3 8 8
----------------------------------------------------------------------
  Webdesign Portfolio                     http://nuno.homepage.nu
    e . t o p i a       -in construction- http://etopia.homepage.nu
 C h a o s  S q u a d                     http://gollop.homepage.nu
      L i m b o                           http://limbo.homepage.nu
----------------------------------------------------------------------

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu