News:

Function Finder  Find all the functions within source code files

Main Menu

Palette Mapped Example (16bit)

Started by kevin, August 18, 2016, 11:03:01 AM

Previous topic - Next topic

kevin

   Palette Mapped Example (16bit)

 This example shows the very basics of creating 16bit palette mapped image using the palette mapping library (slib).     The actual image is just a normal 16bit RGB image in FX format, so we can render to it using most draw operations.      In this case we're using Circle and CLS to fill the image with the required palette indexes.   Now since the original commands only render in RGB's,  we need to convert our palette indexes to RGB using IndexToRGB,  which just bit shifts/converts the input data into a 32bit RGB colour form.   So when that colour is  drawn to the surface, it becomes the same value.  




PlayBASIC Code: [Select]
   #include "Palettemapping"


; Define array we'll use for the palette
Dim Palette($10000)
SetPalette Palette()


; set colour 620 palette index purple
Palette(620) = rgb (255,0,255)

; set colour 7483 to GREEN in the palette
Palette(7483) = rgb (0,255,0)


; make a image for that we'll use for palette mapped rendering
PaletteMappedImage = NewPaletteMapImage(800,600)



; ----------------------------------
; Start of programs main loop
; ----------------------------------
Do

; set cursor position to top left croner
SetCursor 0,0

; render to the Palette mapped image
rendertoimage PaletteMappedImage


; fill this image with colour 620 from the palette
cls indextorgb(620)


; fill this circle with colour 7483 from the palette
Circlec mousex(),mousey(), 100, true, IndextoRgb(7483)


; set rendering back to the screen
rendertoscreen


; check if a mouse button is pressed
if Mousebutton()=false

; draw as palette mapped
drawpalettemapimage PaletteMappedImage,0,0
print "Rendering Palette Mapped"


else

; draw actual RGB version of the image to the screen
; so we can see these they are different
drawimage PaletteMappedImage,0,0,false
print "Rendering as bitmap"

endif



; flip the screens back buffers and
Sync

; loop until a key is pressed
loop scancode() >0







  Related Examples

     * Palette Mapped / Raster Bar Examples

     * Classic Glenz Vector

     * Glenz Vector Cube

     * 8bit / 16bit palette mapped strips

     * Shadows / Recolouring

      * Load Compressed 8bit Palette Mapped Images from Data Statements
   
       * Vampire Demo (16bit)