Another tech.for saving images as transparent PNG
Hope you like it
Code: Select all
UsePNGImageDecoder()
UsePNGImageEncoder()
Global lBrush1.LOGBRUSH, Pen.l, hdc.l
With lBrush1
\lbStyle = #BS_SOLID
\lbColor = #Blue
EndWith
Pen = ExtCreatePen_(#PS_GEOMETRIC|#PS_ENDCAP_ROUND|#PS_JOIN_MITER|#PS_SOLID, 10, lBrush1, 0, 0)
;Create image with 24 bit color depth (Not required in all cases)
CreateImage(0, 300, 300, 24)
hdc=StartDrawing(ImageOutput(0))
Box(0,0,300,300,#White)
SelectObject_(hdc, Pen)
MoveToEx_(hdc,100,100,0)
LineTo_(hdc,200,200)
StopDrawing()
;******************* In case of any image *************
; LoadImage(0,"g:\girl.bmp")
; CreateImage(1, ImageWidth(0),ImageHeight(0), 32)
; StartDrawing(ImageOutput(1))
; DrawImage(ImageID(0),0,0)
; StopDrawing()
;Convert the image To 32 bit color depth
CreateImage(1, ImageWidth(0),ImageHeight(0), 32)
StartDrawing(ImageOutput(1))
DrawImage(ImageID(0),0,0)
StopDrawing()
;Change the alpha value for every white (Or any other color you like) pixel to transparent
StartDrawing(ImageOutput(1))
For x = 0 To ImageWidth(0) - 1
For y = 0 To ImageHeight(0) - 1
DrawingMode(#PB_2DDrawing_Default )
If Point(x,y) = #White
DrawingMode(#PB_2DDrawing_AllChannels )
Plot(x,y,RGBA(255, 255, 255,0))
EndIf
Next
Next
StopDrawing()
SaveImage(1,"toto000123.png",#PB_ImagePlugin_PNG)
FreeImage(1)
RunProgram("toto000123.png")