Maybe I must use WinAPI in this time
How to draw a half-transparent image in window?
-
Michael Korolev
- User

- Posts: 53
- Joined: Wed Nov 01, 2006 3:02 pm
- Location: Russia/Krasnoyarsk
- Contact:
How to draw a half-transparent image in window?
How to draw a transparent or half-transparent image in window? I need to use loaded image as transparent background... to see content of window 
Maybe I must use WinAPI in this time
Maybe I must use WinAPI in this time
Last edited by Michael Korolev on Fri Nov 03, 2006 8:47 pm, edited 1 time in total.
-
Michael Korolev
- User

- Posts: 53
- Joined: Wed Nov 01, 2006 3:02 pm
- Location: Russia/Krasnoyarsk
- Contact:
-
Edwin Knoppert
- Addict

- Posts: 1073
- Joined: Fri Apr 25, 2003 11:13 pm
- Location: Netherlands
- Contact:
- netmaestro
- PureBasic Bullfrog

- Posts: 8452
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
I'm not sure what you're trying to accomplish. See if this has anything of interest to you:
Code: Select all
dark = RGB(113,126,80)
light = RGB(237,229,190)
off = 35
CreateImage(0,582,582)
StartDrawing(ImageOutput(0))
Box(0,0,582,582,light)
For j = off To off+448 Step 128
For i = 64 To 532 Step 128
Box(i+off,j,64,64,dark)
Box((i-64)+off,j+64,64,64,dark)
Next
Next
DrawingMode(#PB_2DDrawing_Outlined)
Box(off-1,off-1,514,514,dark)
Box(off-6,off-6,524,524,dark)
Box(off-10,off-10,532,532,dark)
FillArea(off-9,off-9,dark,dark)
Box(off-35,off-35,582,582,0)
StopDrawing()
main = OpenWindow(0,0,0,582,582,"Alpha Background Test",$CF0001)
SetWindowLong_(main, #GWL_EXSTYLE, GetWindowLong_(main, #GWL_EXSTYLE) | #WS_EX_LAYERED )
SetLayeredWindowAttributes_(main, 0, 100, #LWA_ALPHA)
hBrush = CreatePatternBrush_(ImageID(0))
SetClassLong_(main,#GCL_HBRBACKGROUND,hBrush)
InvalidateRect_(main,0,1)
Repeat:Until WaitWindowEvent() = #WM_CLOSE
-
Edwin Knoppert
- Addict

- Posts: 1073
- Joined: Fri Apr 25, 2003 11:13 pm
- Location: Netherlands
- Contact:
Nice!
Hmmm.
If: Sparkie is to Batman then:
.. as Netmaestro is to ????
.. as srod is to ????
Some possible candidates: Spiderman, Phantom (ghost who walks), Biggles, Thor, Captain America, Catwoman, Noddy, Green Arrow, Roy of the Rovers, Red Lantern, Buck Rogers, Roy Rogers, Tonto ...
But .. who will become Superman!
Hmmm.
If: Sparkie is to Batman then:
.. as Netmaestro is to ????
.. as srod is to ????
Some possible candidates: Spiderman, Phantom (ghost who walks), Biggles, Thor, Captain America, Catwoman, Noddy, Green Arrow, Roy of the Rovers, Red Lantern, Buck Rogers, Roy Rogers, Tonto ...
But .. who will become Superman!
Dare2 cut down to size
-
Michael Korolev
- User

- Posts: 53
- Joined: Wed Nov 01, 2006 3:02 pm
- Location: Russia/Krasnoyarsk
- Contact:
I almost decided this problem. I did so:
Image becomes transparent. But different background color of gadgets produces annoying "stripes", see here:

I think, I need to change background color of gadgets to transparate. But again! I can't find this function. Really, can I do it without WinAPI?
Code: Select all
hWnd=WindowID(0)
hImage=LoadImage(0,bgimage$)
hImagelist=ImageList_Create_(400,300,#ILC_COLORDDB,1,0)
ImageList_Add_(hImagelist,hImage,RGB(0,0,0))
hDc=BeginPaint_(hWnd,@ptst)
ImageList_Draw_(hImagelist,0,hDc,0,0,#ILD_BLEND)
EndPaint_(hWnd,@ptst)
I think, I need to change background color of gadgets to transparate. But again! I can't find this function. Really, can I do it without WinAPI?
