CreateImage() with any color
Posted: Wed Jan 26, 2011 2:42 pm
Currently, CreateImage() defaults to black when used. Can an optional color be set, so we don't need to StartDrawing() a Box() with a specific color, after creating it?
http://www.purebasic.com
https://www.purebasic.fr/english/
Code: Select all
Procedure CreateImageEx(Image.i, Width.i, Height.i, Depth.i=24, Color.l=$00000000)
If Image = #PB_Any
Image = CreateImage(Image, Width, Height, Depth)
Else
CreateImage(Image, Width, Height, Depth)
EndIf
If IsImage(Image)
StartDrawing(ImageOutput(Image))
DrawingMode(#PB_2DDrawing_AllChannels)
Box(0, 0, Width, Height, Color)
StopDrawing()
EndIf
EndProcedure
Macro CreateImage(Image, Width, Height, Depth=24, Color=$00000000)
CreateImageEx(Image, Width, Height, Depth, Color)
EndMacro
Code: Select all
CreateImage(#Image, Width, Height, 32|#PB_Image_Transparent)