UnderwareDESIGN

PlayBASIC => Resources => Source Codes => Topic started by: kevin on July 11, 2007, 02:20:04 PM

Title: BlitImageAlphaMultColour
Post by: kevin on July 11, 2007, 02:20:04 PM
 
Added a Colour mult blit mode.  Bellow shows how it can be used to colour an image and fade it in/out without changing the original image.    



This code is for  PB1.63h retail.



[pbcode]


   #include "Blitimage"

   LoadFXIMage "..\..\..\gfx\tree.jpg",1
   
   FadeCol=rgb(255,255,255)

   NextChange=timer()+5000
   
   Do   
         ; Ping/ pong the Fade colour
         FadeLevel#=cosNewvalue(50,angle#,50)

         ; Move the angle to keep the image fading in/out
         angle#=wrapangle(angle#,1)


         ; Calc the fade col to merge with the image during the blit
         Col=rgbfade(FadeCol,FadeLevel#)


         ; Draw them around the screen to create infinite scrolling platfeild
         
         For lp=-Xpos to 800 Step 800
            ; Blit the Image scaled by the fade colour
            BlitImageAlphaMultColour 1,lp,0,col
         next      

         ; Change the Xpos   
         Xpos=mod(Xpos+1,800)
         
         

         ; Randomly Change the fade colour
         if Spacekey()=true or Timer()>NextChange
            NextChange=timer()+5000

            FadeCOl=RndRgb()
         endif



         ; Display the FPS
         text 10,10,fps()   

      ; Show the display   
      Sync
   loop
   

[/pbcode]


Title: Re: BlitImageAlphaMultColour
Post by: kevin on July 12, 2007, 12:06:07 AM
 Here's the MMX (machine code) opt'd version. About 100fps faster in 32bit.

Also, the MMX 16bit version clocks at 550fps now.
Title: Re: BlitImageAlphaMultColour
Post by: Adaz on July 14, 2007, 01:31:02 AM
Very nice!
But...you forgot to include the new BlitImage.PBA with BlitImageAlphaMultColour  ;)
Title: Re: BlitImageAlphaMultColour
Post by: kevin on July 14, 2007, 01:33:25 AM

See,

Quote
This code is for  PB1.63h retail.