coda
Junior Member
Posts: 74
|
Post by coda on Apr 8, 2024 1:06:39 GMT -5
I should probably know this... but is there a way to draw images with a transparent background to a graphics box using LB... or win32api? Side question: Is there a way to rotate images easily though an arbitrary number of degrees... like 3.5 degrees etc? All help and suggestions most gratefully appreciated.
|
|
|
Post by Rod on Apr 8, 2024 1:37:37 GMT -5
|
|
|
Post by tsh73 on Apr 8, 2024 2:18:22 GMT -5
Native LB way: sprites, in a help file No arbitrary rotation though (only flip and miror)
|
|
|
Post by Rod on Apr 8, 2024 4:01:53 GMT -5
|
|
coda
Junior Member
Posts: 74
|
Post by coda on Apr 9, 2024 23:02:46 GMT -5
Thanks so much! You guys rock! The people at this forum are AMAZING. I shall work through the examples.
|
|
|
Post by xxgeek on Apr 10, 2024 9:47:36 GMT -5
Not sure if this applies but it might be useful.
Draw on a Transparent Window
'An example of drawing on a transparent window 'by xxgeek 'as is the window will continuously fade in and out 'click on the window and drag the mouse to draw 'edit to your liking
nomainwin WindowWidth = DisplayWidth WindowHeight = DisplayHeight UpperLeftX=INT((DisplayWidth-WindowWidth)/2) UpperLeftY=INT((DisplayHeight-WindowHeight)/2) button #1.gbx, "Close Window", [quit],UL INT((DisplayWidth)/2)-50, 5, 200, 50 graphicbox #1.gbx ,0 ,0 ,DisplayWidth ,DisplayHeight open "" for window_popup as #1 #1 "trapclose [quit]" #1 "font arial 20 bold" #1.gbx "when leftButtonDown [draw]" #1.gbx "when leftButtonUp [loop]" #1.gbx "when leftButtonMove [mouseMoved]" winPop = hwnd(#1)
[loop] do scan call CreateTransparentWindow winPop, f f=f+2 timer 50, [done] wait [done] timer 0 loop until f=250 do scan call CreateTransparentWindow winPop, f 'between 0 - 255 f=f-2 timer 50,[done2] wait [done2] timer 0 loop until f=10 goto [loop]
[quit] close #1 end
[draw] #1.gbx "color red" #1.gbx "home; down" wait
[mouseMoved] #1.gbx "color red" #1.gbx "size 12" #1.gbx "set ";MouseX;" ";MouseY wait
sub CreateTransparentWindow winPop, transparency calldll #user32, "GetWindowLongA", winPop as ulong, -20 as long, r as long x = r or 524288 calldll #user32, "SetWindowLongA", winPop as ulong, -20 as long, x as long, r as long calldll #user32, "SetLayeredWindowAttributes", winPop as ulong, 0 as long, transparency as long, 2 as long, r as long end sub
|
|
coda
Junior Member
Posts: 74
|
Post by coda on Apr 11, 2024 21:51:24 GMT -5
Thankyou so much xxgeek! It certainly might. I'll examine it properly tonight. It looks brilliant.
|
|
coda
Junior Member
Posts: 74
|
Post by coda on Apr 11, 2024 21:55:35 GMT -5
Rod, This all looks brilliant. I am having some trouble with the PlgBlt example though. The mask won't work. I assume it works on Windows and therefore maybe there is a bug in the Wine blitter as I'm running on Ubuntu Linux through Wine. Not sure why it won't work for me...
|
|
|
Post by Rod on Apr 12, 2024 1:51:30 GMT -5
Never heard of the demo not working before and it’s an old demo. John would need to tell us if Wine creates any issues. In the meantime be sure you have not got errors in the rotation values, just copy paste the demo. Also when creating the mask bmp it MUST be a two colour image. Be sure it has not been transformed in the copying process.
Also. how do you know the mask does not work, what happens on screen?
|
|
coda
Junior Member
Posts: 74
|
Post by coda on Apr 12, 2024 7:38:47 GMT -5
I copied and pasted you demo and the bmps. I opened the mask in photoshop to check. It is still a two colour image and has not changed. I know because, the needle is surrounded by a black sheet which rotates with it. Hope this helps.
|
|
|
Post by Rod on Apr 12, 2024 7:50:06 GMT -5
Ok, we need another Wine user to confirm.
|
|
|
Post by xxgeek on Apr 12, 2024 11:02:03 GMT -5
I just blew away my Linux partition. A cheap SSD lasted me about 2 years, if that.
Luckily I have a tiny notepad with Linux and WINE installed. Frustrating but doable.
I tested each of the code samples provided by Rod and they all seem to work using the file attachments provided.
"Seems" is the key word since I am unsure of what exactly I should be seeing.
I believe I am seeing what coda is seeing.
Should we be seeing a blue circle with each hour marked in yellow and a yellow arrow inside it, with NO Black circle.
We don't see a yellow arrow in the blue circle. It is always in a black circle. Since it is constantly in motion as it rotates, the arrow never shows in the blue circle.
I wish I could show a visual of it, but how?
|
|
|
Post by xxgeek on Apr 12, 2024 11:24:15 GMT -5
Ok, my brain started up.
I checked everything in Windows 10 Pro to see how it should look.
Obviously a WINE issue. Maybe one of the dll's being called needs some support file(s) installed, or possibly it is an old version of gdi32.dll in WINE.
I'll keep poking around, it's raining outside.
|
|
|
Post by xxgeek on Apr 12, 2024 13:47:01 GMT -5
Well, no luck so far with a few ideas.
I have another example of a transparent window you can draw on though. I took out the looping fade so it is simpler to work with
'click on the window and drag mouse to draw 'try different color backgrounds - see in code 'you can stretch the window over the entire display 'set different transparency - see in code
'An example of drawing on a transparent window 'by xxgeek 'click on the window and drag the mouse to draw 'edit to your liking
nomainwin WindowWidth = 600 WindowHeight = 400 graphicbox #1.gbx ,0 ,0 ,DisplayWidth ,DisplayHeight open "" for window as #1 #1 "trapclose [quit]" #1.gbx "when leftButtonDown [draw]" #1.gbx "when leftButtonUp [loop]" #1.gbx "when leftButtonMove [mouseMoved]" #1.gbx "backcolor cyan" 'try different background colors or comment out window = hwnd(#1) f=155 'set between 0 and 255 for transparency level_ '_ - at low numbers you may not see your drawing, or the Transparent window. '_Use ALT + F4 to close the window if you can't see it.
call CreateTransparentWindow window, f [loop] wait
[quit] close #1 end
[draw] wait
[mouseMoved] #1.gbx "home; down" #1.gbx "color red" #1.gbx "size 10" #1.gbx "set ";MouseX;" ";MouseY wait
sub CreateTransparentWindow window, transparency calldll #user32, "GetWindowLongA", window as ulong, -20 as long, r as long x = r or 524288 calldll #user32, "SetWindowLongA", window as ulong, -20 as long, x as long, r as long calldll #user32, "SetLayeredWindowAttributes", window as ulong, 0 as long, transparency as long, 2 as long, r as long end sub '
|
|
|
Post by Rod on Apr 12, 2024 15:02:42 GMT -5
What you should see is the blue dial with the yellow pointer spinning round. Ther should be no black bits. Perhaps if we knew what type of graphic and what type of rotation we might offer alternative solutions.
|
|