CreateFxImageEx
CreateFxImageEx ImageIndex, Width, Height, Depth
 
Parameters:

    ImageIndex = The Index of the image that you wish to create.
    Width = The width of the image in pixels
    Height = The Height of the image in pixels
    Depth = The Colour Depth of this image
Returns: NONE
 

      CreateFxImageEx is unique in terms of PB graphic commands. CreateFxImageEx is the only command that lets you not only specify the size (width & height) of the image, but you can also select the colour depth of this image.

      This is unique as the PlayBASIC graphics engine was designed to automatically scale image colour depths to match of the PB screens colour depth. Meaning that if you open a 16bit screen, then images will also be stored in this format. This is done to ensure the most efficient path when transferring image data to the screen

      However, I can see a point where it might be useful for a programmer to open an image that is of a specific colour format, regardless of the current screen modes. While you can draw to these images using the normal vector graphics commands (dot, line, box etc etc) you'll only be able to draw images to them that have the same colour depth.

Depth values and colour formats

      15Bit = RGB Colour format 555 (each pixel is a word (2 bytes))
      16Bit = RGB Colour format 565 (each pixel is a word (2 bytes))
      24Bit = RGB Colour format 888 (each pixel is 3 bytes)
      32Bit = RGB Colour format -888 (each pixel is a Long/Integer (4 bytes))





FACTS:


      * While CreateFxImageEx allows you to create an Image that is of a different depth than the display. The drawing commands like DrawImage can actually translate pixel formats when drawing mismatched image buffers while drawing. Please be aware that depending upon the pixel format, the operation may change the colours of the drawn image.


DrawImage Format Conversion conversion table



Drawing to 15bit Buffer

15bit to 15bit = [Yes]
16bit to 15bit = [Yes]
24bit to 15bit = [Yes]
32bit to 15bit = [Yes]


Drawing to 16bit Buffer

15bit to 16bit = [Yes]
16bit to 16bit = [Yes]
24bit to 16bit = [Yes]
32bit to 16bit = [Yes]



Drawing to 24bit Buffer

15bit to 24bit = [Yes]
16bit to 24bit = [Yes]
24bit to 24bit = [Yes]
32bit to 24bit = [Yes]


Drawing to 32bit Buffer

15bit to 32bit = [Yes]
16bit to 32bit = [Yes]
24bit to 32bit = [Yes]
32bit to 32bit = [Yes]






 
Example Source: Download This Example
; Note: this demo opens a 32bit screen mode.
  OpenScreen 800,600,32,2
  
  
;Clear the Screen to Blue
  Cls RGB(0,0,255)
  w=200
  h=400
  Print "32 bit Screen Mode"
  
  
; create a 15bit (555) FX buffer
  CreateFXImageEx 1,w,h,15
  
; create a 16bit (565 ) FX buffer
  CreateFXImageEx 2,w,h,16
  
; create a 24bit (888 RGB) FX buffer
  CreateFXImageEx 3,w,h,24
  
; create a 32bit (8888 - ARGB) FX buffer
  CreateFXImageEx 4,w,h,32
  
  
  c1=$ff0000
  c2=$00ff00
  c3=$0000ff
  
  For lp=0 To 100
     x1=Rnd(w)
     y1=Rnd(h)
     x2=Rnd(w)
     y2=Rnd(h)
     x3=Rnd(w)
     y3=Rnd(h)
     
     For Img=1 To 4
        RenderToImage Img
        GouraudTri x1,y1,c1,x2,y2,c2,x3,y3,c3
     Next
     
  Next
  
  RenderToScreen
  For Img=1 To 4
     x=(w+10)*(img-1)
     y=100
     DrawImage img,x,y,0
     Text x,y,Str$(GetImageDepth(img))+" bit"
  Next
  
; display screen and wait for a key to be pressed
  Sync
  WaitKey
  
  
  
  
  
 
Related Info: CreateImage | DeleteImage | DrawImage | GetFreeImage | LoadImage | NewImage | PrepareFXimage | RenderToImage :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com