Save the clp_00.png file from the Source image (in the 1st post) and open it in Gimp. You will see a rounded edge without artifacts. Now run the above code with clp_00.png and copy the clipboard into Gimp. The rounded edge has a darker line on it (like the XnView image 1st post).
To fix this problem we should apply Premultiply Alpha calculations:
Code: Select all
Procedure PreMultiplyAlpha(image)
StartDrawing(ImageOutput(image))
DrawingMode(#PB_2DDrawing_AllChannels)
w = ImageWidth(image) - 1
h = ImageHeight(image) - 1
For y=0 To h
For x=0 To w
color = Point(x, y)
Plot(x, y, RGBA((Red(color) * Alpha(color) + 127) * 0.00392156, (Green(color) * Alpha(color) + 127) * 0.00392156, (Blue(color) * Alpha(color) + 127) * 0.00392156, Alpha(color)))
Next
Next
StopDrawing()
ProcedureReturn image
EndProcedure
UsePNGImageDecoder()
LoadImage(0, "clp_00.png")
PreMultiplyAlpha(0)
SetClipboardImage(0)