Page 1 of 2
How to draw a half-transparent image in window?
Posted: Fri Nov 03, 2006 8:43 pm
by Michael Korolev
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

Posted: Fri Nov 03, 2006 8:46 pm
by IceSoft
Use the DX9 SubSystem from Stefan
Posted: Fri Nov 03, 2006 8:49 pm
by Michael Korolev
I AM BEGINNER. What a DX9 yet? Be simpler, please...
Posted: Fri Nov 03, 2006 9:06 pm
by Edwin Knoppert
I think you mean alpha blending.
I guess you'll need to focus on the gdiplus (gdi+) library.
Posted: Fri Nov 03, 2006 9:10 pm
by netmaestro
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
Posted: Fri Nov 03, 2006 10:09 pm
by Edwin Knoppert
Wow, learned something new today

Posted: Fri Nov 03, 2006 10:36 pm
by Dare
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!
Posted: Fri Nov 03, 2006 11:54 pm
by Henrik
Dare wrote:
But .. who will become Superman!
Fred doesn't become, Fred IS! .. thssss..

Posted: Fri Nov 03, 2006 11:55 pm
by Dare
Fred is already at the Deity level. Why demote him?
Posted: Fri Nov 03, 2006 11:56 pm
by Flype
Posted: Fri Nov 03, 2006 11:58 pm
by Henrik
Posted: Sat Nov 04, 2006 5:40 am
by PB
Posted: Sat Nov 04, 2006 2:39 pm
by thamarok
Posted: Sun Nov 05, 2006 2:49 pm
by SoulReaper
Posted: Mon Nov 06, 2006 2:00 pm
by Michael Korolev
I almost decided this problem. I did so:
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)
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?