It is currently Mon Dec 11, 2017 1:25 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: [5.46 LTS B1] ImageGadget transparency issues
PostPosted: Wed Dec 06, 2017 10:59 am 
Offline
Addict
Addict
User avatar

Joined: Mon Jun 06, 2005 2:35 pm
Posts: 1079
Location: germany
[EDIT] Remove usage of some external PNG test image. Now use self drawn [/EDIT]

This code:

Code:
UsePNGImageDecoder()

a.s = "<?xml version='1.0' ?>"
a.s + "<window name='mainWindow'"
a.s + "        text='window text'"
a.s + "        width='780'"
a.s + "        height='500'"
a.s + "        margin='0'"
a.s + "        flags='#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_TitleBar|#PB_Window_SizeGadget|#PB_Window_MaximizeGadget|#PB_Window_Invisible|#PB_Window_ScreenCentered'>"
a.s + "  <vbox expand='item:2' spacing='0'>"
a.s + "    <!-- header image -->    "
a.s + "    <image name='image' height='40' width='auto' />"
a.s + "    <!-- grid -->"
a.s + "    <listicon name='listicon' flags='#PB_ListIcon_AlwaysShowSelection|#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect|#PB_ListIcon_MultiSelect' />"
a.s + "    <!-- spacer -->"
a.s + "    <singlebox margin='2' />"
a.s + "    <!-- button bar -->"
a.s + "    <hbox height='70' expand='item:4'>"
a.s + "      <empty />"
a.s + "      <image name='logo' width='64' height='64'/>"
a.s + "      <empty width='20'/>"
a.s + "      <text name='label' flags=''/>"
a.s + "      <empty />"
a.s + "      <button name='Button_help' width='30' />"
a.s + "      <empty />"
a.s + "      <button name='Button_refresh' width='60' />"
a.s + "      <button name='Button_send' width='60' />"
a.s + "    </hbox>"
a.s + "    <singlebox margin='5' />"
a.s + "  </vbox>"
a.s + "</window>"

a.s = ReplaceString(a.s, "\q", Chr(34)) ; get quotes back
; Debug a.s

If CreateFile(0, GetTemporaryDirectory() + "test.xml")
  WriteString(0, a.s)
  CloseFile(0)
EndIf

xml.i = LoadXML(#PB_Any, GetTemporaryDirectory() + "test.xml")

d.i = CreateDialog(#PB_Any)

w.i = OpenXMLDialog(d.i, xml.i, "")
If w.i = 0
  Debug DialogError(d.i)
  End
EndIf

logo.i = DialogGadget(d.i, "logo")

HeaderImageID.i = CreateImage(#PB_Any, 64, 64, 32, #PB_Image_Transparent)
StartDrawing(ImageOutput(HeaderImageID.i))
DrawingMode(#PB_2DDrawing_AllChannels)
Circle(32,32, 18, RGBA(0,0,0,20))
Circle(32,32, 15, RGBA(100,255,120,255))
StopDrawing()
SetGadgetState(logo.i, ImageID(HeaderImageID.i))

SmartWindowRefresh(DialogWindow(d.i), 1)

HideWindow(DialogWindow(d.i), #False)

Repeat
  Event.i = WaitWindowEvent()
Until Event.i = #PB_Event_CloseWindow


Looks like this after some movement and resize (Windows 7):
Image

Three things realized:
1) The image background seems to mix with the background of the underlying window (here PB IDE).
2) The image is redrawn and this corrupts transparency (the shadow borders of the image turn black)
3) On Linux it works like expected (background is window background, transparency stays)

Without SmartWindowRefresh() it is better, but still not okay. If you slowly resize the width of the window (not height!), you still realize that the transparent shadow around the circle is overdrawn and getting darker. The image is not refreshed correctly.


Top
 Profile  
Reply with quote  
 Post subject: Re: [5.46 LTS B1] ImageGadget transparency issues
PostPosted: Thu Dec 07, 2017 11:05 am 
Offline
Enthusiast
Enthusiast

Joined: Tue May 26, 2009 2:11 pm
Posts: 453
Kukulkan wrote:
[EDIT] Remove usage of some external PNG test image. Now use self drawn [/EDIT]
...
You can also avoid saving and loading the XML:
Replace
Code:
...
If CreateFile(0, GetTemporaryDirectory() + "test.xml")
  WriteString(0, a.s)
  CloseFile(0)
EndIf

xml.i = LoadXML(#PB_Any, GetTemporaryDirectory() + "test.xml")
...
with
Code:
xml.i=CatchXML(#PB_Any, @a, StringByteLength(a, #PB_Unicode), #PB_XML_StreamStart, #PB_Unicode)

This has nothing to do with the mentioned bug, but I don't like to have all these temporarely stored pieces. At least they should be deleted after been catched.

_________________
I'm an official dummy!
Image


Top
 Profile  
Reply with quote  
 Post subject: Re: [5.46 LTS B1] ImageGadget transparency issues
PostPosted: Thu Dec 07, 2017 7:56 pm 
Offline
PureBasic Team
PureBasic Team
User avatar

Joined: Fri Apr 25, 2003 5:21 pm
Posts: 5747
Location: Germany
Lord wrote:
Code:
xml.i=CatchXML(#PB_Any, @a, StringByteLength(a, #PB_Unicode), #PB_XML_StreamStart, #PB_Unicode)


It is even simpler these days:
Code:
xml.i = ParseXML(#PB_Any, a)

_________________
quidquid Latine dictum sit altum videtur


Top
 Profile  
Reply with quote  
 Post subject: Re: [5.46 LTS B1] ImageGadget transparency issues
PostPosted: Fri Dec 08, 2017 8:06 am 
Offline
Addict
Addict
User avatar

Joined: Mon Jun 06, 2005 2:35 pm
Posts: 1079
Location: germany
Thanks for the hints about the XML functions but it looks like I really can't use PB 5.46 because of this IMAGE bug.

For my users it currently looks like this:
Image

And after some resizing and moving, it looks like this:
Image

Can you please confirm the bug? Or is it just on my machines? Or is there a way around? Looks like all transparency in images is somehow not working. Do I need to draw a background into the images before using them in XML dialog?


Top
 Profile  
Reply with quote  
 Post subject: Re: [5.46 LTS B1] ImageGadget transparency issues
PostPosted: Fri Dec 08, 2017 9:44 am 
Offline
Enthusiast
Enthusiast

Joined: Tue May 26, 2009 2:11 pm
Posts: 453
Kukulkan wrote:
...
Can you please confirm the bug?
...
I can confirm this bug using PB5.60(x64) and PB5.60(x86).

_________________
I'm an official dummy!
Image


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye