Page 1 of 1

CreateImage() with any color

Posted: Wed Jan 26, 2011 2:42 pm
by C64
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?

Re: CreateImage() with any color

Posted: Wed Jan 26, 2011 5:03 pm
by STARGÅTE
The picture is after the create empty
empty = 0 = $000000 = black
so its black ;-)

You can use a macro to expand the command:

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

Re: CreateImage() with any color

Posted: Thu Jan 27, 2011 1:03 am
by C64
My request is to avoid using StartDrawing() after it, like I said in my first post. ;) Especially since I only use CreateImage() once in my program, so making a macro for it is a waste of space. It'd be nice just to be able to type in CreateImage(#PB_Any,w,h,color) instead.

Re: CreateImage() with any color

Posted: Sat Jun 02, 2012 2:22 pm
by A.D.
How can i make the background transparent ? I tried all alpha channels but the background remains black for me. I need an "empty" background

Re: CreateImage() with any color

Posted: Sat Jun 02, 2012 2:31 pm
by STARGÅTE
use the #PB_Image_Transparent constant

Code: Select all

CreateImage(#Image, Width, Height, 32|#PB_Image_Transparent)
this image is an empty image

Re: CreateImage() with any color

Posted: Sat Jun 02, 2012 5:45 pm
by A.D.
Thx :-)