[5.42] vector drawing & saveImage()
Posted: Mon Mar 28, 2016 3:10 pm
Hi
There is a bug with SaveImage() and the vector drawing library, with alpha chanel.
On the result, we can see a black border :

Code to test :
I m' not sur, but, perhap's for transparent pixels, the color to erase shouldn't be the black, but the color of the pixel (premul mode ?).
Fr :
Il y a un bug lorsqu'on sauvegarde une image avec canal alpha (png). On voit un liseret (bordure) noire autour des formes avec transparence.
Je ne suis pas certain, mais peut-être que lors de l'enregistrement, les pixels transparents (<255 et >0) devraient être effacés avec la couleur du pixel et non la couleur noire
.
There is a bug with SaveImage() and the vector drawing library, with alpha chanel.
On the result, we can see a black border :

Code to test :
Code: Select all
Procedure DrawVector()
AddPathCircle(75, 100, 60)
VectorSourceColor(RGBA(255, 240, 200, 255))
FillPath()
AddPathCircle(125, 100, 60)
VectorSourceColor(RGBA(210, 250, 255, 207))
FillPath()
; Dessin opaque sur une couche semi-transparente
BeginVectorLayer(240)
AddPathCircle(275, 100, 60)
VectorSourceColor(RGBA(255, 240, 240, 255))
FillPath()
AddPathCircle(325, 100, 60)
VectorSourceColor(RGBA(200,255, 240, 255))
FillPath()
EndVectorLayer()
EndProcedure
If OpenWindow(0, 0, 0, 400, 200, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CanvasGadget(0, 0, 0, 400, 200)
If StartVectorDrawing(CanvasVectorOutput(0))
DrawVector()
StopVectorDrawing()
EndIf
UsePNGImageEncoder()
File$ = SaveFileRequester("Save Image...", File$, "png Images|*.png|All Files|*.*", 0)
If File$ <> ""
If CreateImage(0, GadgetWidth(0), GadgetHeight(0), 32,#PB_Image_Transparent)
If StartDrawing(ImageOutput(0))
DrawingMode(#PB_2DDrawing_AllChannels)
Box(0,0,GadgetWidth(0),GadgetHeight(0),RGBA(0,0,0,0))
StopDrawing()
EndIf
If StartVectorDrawing(ImageVectorOutput(0))
DrawVector()
StopVectorDrawing()
EndIf
If SaveImage(0, File$, #PB_ImagePlugin_PNG) = 0
MessageRequester("CanvasGadget", "Cannot save image: " + File$)
EndIf
FreeImage(0)
EndIf
EndIf
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
Fr :
Il y a un bug lorsqu'on sauvegarde une image avec canal alpha (png). On voit un liseret (bordure) noire autour des formes avec transparence.
Je ne suis pas certain, mais peut-être que lors de l'enregistrement, les pixels transparents (<255 et >0) devraient être effacés avec la couleur du pixel et non la couleur noire
