It is currently Wed Oct 28, 2020 6:21 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Linux PB 5.72 Subsystem qt - #PB_Image_Transparent Bug & Fix
PostPosted: Sun Aug 09, 2020 9:16 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Apr 05, 2020 11:28 am
Posts: 276
Location: Pandora
Linux_Mint PB5.72 Subsystem qt

#PB_Image_Transparent Bug

Another qt bug I want to describe here briefly.
Looks really bad and is a important problem - only on Linux with Subsystem qt !
Code:
; The created image has a damaged alpha channel, the buffer is not empty, only transparent images are damaged
    temporary_ID=CreateImage(#PB_Any , width , height , 32 , #PB_Image_Transparent)
   
; This fix the bug
    StartDrawing(ImageOutput(temporary_ID))
    FillMemory(DrawingBuffer() , DrawingBufferPitch() * ImageHeight(temporary_ID) , 0)
    StopDrawing()


Fix - Workaround - Macro - Add to your code
Code:
CompilerIf #PB_Compiler_OS = #PB_OS_Linux And Subsystem("qt")
; CreateImage() Linux Subsystem qt - Fix for Image Transparent Bug - By Saki
  Procedure CreateImage_(image_ID , image_width , image_height , image_depth = 24 , image_color = 0)
    If image_color = #PB_Image_Transparent
      Protected resulted = CreateImage(image_ID , image_width , image_height , 32 , #PB_Image_Transparent)
      If image_ID <> #PB_Any
        resulted = image_ID
      EndIf
      If Not StartDrawing(ImageOutput(resulted))
        If IsImage(resulted)
          FreeImage(resulted)
        EndIf
        ProcedureReturn 0
      EndIf
      FillMemory(DrawingBuffer() , DrawingBufferPitch() * ImageHeight(resulted) , 0)
      StopDrawing()
      ProcedureReturn resulted
    EndIf
    ProcedureReturn CreateImage(image_ID , image_width , image_height , image_depth , image_color)
  EndProcedure
  Macro CreateImage(image_ID , image_width , image_height , image_depth = 24 , image_color  =  0)
    CreateImage_(image_ID , image_width , image_height , image_depth , image_color)
  EndMacro
CompilerEndIf


This indicates that the image buffer was requisitioned but not deleted.

So AllocateMemory is called without clearing the buffer, this is the bug.

Here i have found a little code for demonstrating the Bug, so i must not make one self.

The Bugfix - Workaround i have included in this code, deactivate simple the TODO Lines for look the Bug.

You must set Subsystem qt in the PB Compileroptions !

https://www.purebasic.fr/english/viewtopic.php?f=23&t=73899

_________________
地球上の平和


Last edited by Saki on Mon Aug 10, 2020 6:16 pm, edited 1 time in total.

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

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