Page 1 of 1
Draw image to screen with transparency
Posted: Fri Nov 17, 2023 2:06 am
by coco2
Is it possible to draw an image to the screen with transparency? The method in the built in help file doesn't seem to work for me. IE I'm trying to create an image using:
Code: Select all
CreateImage(0, 600, 600, 32, #PB_Image_Transparent)
And then drawing to the image using vector functions and subsequently drawing the image to screen does not keep the transparency.
Re: Draw image to screen with transparency
Posted: Fri Nov 17, 2023 3:21 am
by coco2
I found it, DrawAlphaImage works
Does anyone know why the coordinates of DrawAlphaImage do not match up with the current window? I'm using a 4K screen and the width is right but the height appears to be 1440. So when I draw an image at Y=1000 it's nearly at the bottom of the screen but the 4K resolution is 3840x2160.
Re: Draw image to screen with transparency
Posted: Sat Nov 18, 2023 12:33 am
by SPH
Please : a small exemple to illustrate that ?

Re: Draw image to screen with transparency
Posted: Sat Nov 18, 2023 4:29 am
by coco2
If I run this on a 4K monitor:
Code: Select all
DWidth.i = DesktopWidth(0)
DHeight.i = DesktopHeight(0)
OpenWindow(0, 0, 0, DWidth, DHeight, "Test", #PB_Window_Maximize | #PB_Window_BorderLess)
InitSprite()
OpenWindowedScreen(WindowID(0), 0, 0, WindowWidth(0), WindowHeight(0), #False, 0, 0, #PB_Screen_WaitSynchronization)
Debug "Resolution detected: " + DWidth + " x " + DHeight
Debug "Resolution effective: " + WindowWidth(0) + " x " + WindowHeight(0)
InitKeyboard()
Repeat
Event = WaitWindowEvent()
ExamineKeyboard()
Esc_Pressed = KeyboardPushed(#PB_Key_Escape)
Until Event = #PB_Event_CloseWindow Or Esc_Pressed
the result I get is:
Resolution detected: 3840 x 2160
Resolution effective: 2560 x 1440
I don't get the full 4K resolution when I have a WindowedScreen.
Note: edited code to only check the first monitor
Re: Draw image to screen with transparency
Posted: Sat Nov 18, 2023 9:02 am
by miso
You iterate trough your monitors to get screen data, but you store and use the parameters of the last one only. (The primary (0 indexed) is overwritten, when you have more than one monitor.)
Re: Draw image to screen with transparency
Posted: Sat Nov 18, 2023 10:03 am
by coco2
Yes but why is it showing the wrong size when I only have one 4K monitor?
Re: Draw image to screen with transparency
Posted: Sat Nov 18, 2023 10:49 am
by miso
Hmm, in that case, I don't have an answer.
Re: Draw image to screen with transparency
Posted: Sat Nov 18, 2023 6:37 pm
by Fig
You juste have one monitor, but do you happen to have more than one windows desktop ?
Re: Draw image to screen with transparency
Posted: Sat Nov 18, 2023 9:19 pm
by HeX0R
change to
Code: Select all
OpenWindowedScreen(WindowID(0), 0, 0, WindowWidth(0) * DesktopResolutionX(), WindowHeight(0) * DesktopResolutionY(), #False, 0, 0, #PB_Screen_WaitSynchronization)
and enable DPI awareness in compiler options
Re: Draw image to screen with transparency
Posted: Sat Nov 18, 2023 10:26 pm
by coco2
I see, it was because I have my desktop set to 150%.
Do you know why when I turn on DPI aware executable I can't alt+tab back to the desktop and it doesn't show the debug window?