// Include the palette Mapping library #Include "PaletteMapping" // ----------------------------------------------------------------- // ----------------------------------------------------------------- // Set Up Palette >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> // ----------------------------------------------------------------- // ----------------------------------------------------------------- // Define a palette big enough to hold 2^16 colours Dim Palette($10000) // Give palette mapping library address of the palette // we're using. SetPalette(Palette()) // Set Colour Index zero to rgb(0,0,0) BLACK Palette(0) = RGB(0,0,0) // Set Colour as out 2 as Palette(1) = RGB(30,40,50) // This number of colours currently in our palette ColourCount=2 // Load the Ship image from the media folder to folders down ShipImage=LoadNewImage(ProgramDir$()+"Help/Commands/Media/ship.bmp") CenterText 250,80,"ORIGINAL RGB IMAGE" DrawImage ShipImage,200,100,false3 // Convert the images normally RGB formated pixels into our // current palette ColourCount=PaletteMapRGBImage(ShipImage,Palette(), ColourCount) CenterText 600,80,"Palette Mapped IMAGE" CenterText 600,170,"Colour Count:"+Str$(ColourCount) DrawImage ShipImage,550,100,false Sync Wait 1000 Wait 1000 // ----------------------------------------------------------------- // ----------------------------------------------------------------- // Create a PB image we'll be using as the Palette Mapped Display // ----------------------------------------------------------------- // ----------------------------------------------------------------- Screen=NewPaletteMapImage(GetScreenWidth(),GetScreenHeight()) Dim BackupPalette($10000) CopyArray Palette(),BackUpPalette() // Limit the program to 75 frames per second or less SetFPS 75 Do // direct all Pb rendering to out screen image RenderToImage Screen // Fill The Screen with colour index 1. // CLS doesn't understand palette mapping, so we have to // convert our colur index into RGB form for drawing to // the screen Cls IndexToRgb(1) // draw our grid of ship images to the screen at the mouses // position GridImage ShipImage,MouseX(),MouseY(),10,10,true // Draw a rotated version of the palette mapped ship image DrawRotatedImage ShipImage,400,300,FadeAngle#,1,1,0,0,true // render our palette mapped screen to the actual screen RenderToScreen DrawPaletteMapImage(Screen,0,0) // -------------------------------------- // Fade palette in and out // -------------------------------------- ScaleLevel=128+Cos(Fadeangle#)*128 ScaleLevel=ClipRange(ScaleLevel,0,255) ShadeRGB=RGB(ScaleLevel,ScaleLevel,ScaleLevel) For lp =1 To ColourCount Palette(lp)=RgbAlphaMult(BackupPalette(lp),ShadeRGB) Next Fadeangle#=WrapAngle(Fadeangle#+1) // show everything to the user Sync Loop EscKey()=true |