UnderwareDESIGN

PlayBASIC => Resources => Source Codes => Topic started by: kevin on March 12, 2008, 11:39:47 PM

Title: TV Static / Black & White Random Noise
Post by: kevin on March 12, 2008, 11:39:47 PM
TV Static / Black & White Random Noise

 This snippets draws a full screen random static pattern.  


[pbcode]

   Width=GetScreenWidth()*2
   height=1

   Img_Cache=NewFxImage(Width,Height)


   Dim Palette(255)
   For lp=0 to 255
      Palette(lp)=rgb(lp,lp,lp)
   next
   

      
   Do
      
         Rendertoimage Img_Cache
         SeedbufferRead=Point(0,0)
         Lockbuffer
         For ylp=0 to Height-1
            For xlp=0 to Width-1
               FastDot xlp,ylp,Palette(rnd(255))
            next
         next
         unLockbuffer

         rendertoscreen
         lockbuffer
         Width2=Width-GetScreenWidth()
         For Ylp=0 to GetScreenHeight()-1
            drawimage img_cache,-rnd(Width2),ylp,0
         next         
         unlockbuffer      
      Sync
   loop

[/pbcode]


Title: Re: TV Static / Black & White Random Noise
Post by: kevin on March 12, 2008, 11:44:05 PM
 Colour Static

[pbcode]

   Width=GetScreenWidth()*2
   height=1

   Img_Cache=NewFxImage(Width,Height)

   Do
      
         Rendertoimage Img_Cache
         SeedbufferRead=Point(0,0)
         Lockbuffer
         For ylp=0 to Height-1
            For xlp=0 to Width-1
               FastDot xlp,ylp,rnd($ffffff)
            next
         next
         unLockbuffer

         rendertoscreen
         lockbuffer
         Width2=Width-GetScreenWidth()
         For Ylp=0 to GetScreenHeight()-1
            drawimage img_cache,-rnd(Width2),ylp,0
         next         
         unlockbuffer      

      Sync
   loop

[/pbcode]


Title: Re: TV Static / Black & White Random Noise
Post by: Adaz on March 13, 2008, 05:44:49 AM
Quote from: kevin on March 12, 2008, 11:44:05 PM
Colour Static
BBC appeared here but only for some seconds, and no sound, why? :)
Title: Re: TV Static / Black & White Random Noise
Post by: kevin on March 24, 2008, 12:50:39 AM
  Here's a version with full screen fading.


[pbcode]

   Width=GetScreenWidth()*2
   height=1
   Img_Cache=NewFxImage(Width,Height)


   Dim Palette(255)
   
   Do

         ; Calc fade level
         FadeLevel=50+CosRadius(FadeANGLE#,50)
         FadeANGLE#=WrapAngle(FadeANGLE#,2)


         ; Seed Faded palette  
         For lp=0 to 255
            C=rgb(lp,lp,lp)   
            Palette(lp)=rgbfade(c,FadeLevel)
         next

         ; Randomize the image strip
         Rendertoimage Img_Cache
         SeedbufferRead=Point(0,0)
         Lockbuffer
         For ylp=0 to Height-1
            For xlp=0 to Width-1
               FastDot xlp,ylp,Palette(rnd(255))
            next
         next
         unLockbuffer

         ; copy ranom strips to the output buffer
         rendertoscreen
         lockbuffer
         Width2=Width-GetScreenWidth()
         For Ylp=0 to GetScreenHeight()-1
            drawimage img_cache,-rnd(Width2),ylp,0
         next         
         unlockbuffer      


      Sync
   loop
[/pbcode]


Title: Re: TV Static / Black & White Random Noise
Post by: kevin on March 07, 2021, 08:05:48 AM


[pbcode]


explicit true

   local bitwidth=2

   local   PixelStepX = 8*BitWIdth      

   local IMage_Frags  = NewfxImage(8*bitwidth,256)
   rendertoimage Image_Frags
   cls $008044
   local lp
   for lp =0 to 256*4
         dotc rnd(8*Bitwidth),lp and 255,$00ffffff
   next
   rendertoscreen   
   local Screen = newfximage(getScreenWidth(),GetScreenheight())
   
   Setfps 100
   Do

      rendertoimage Screen      
//      cls $102030

      
         lockbuffer
         local ThisRGB=point(0,0)
         local xlp,ylp,xpos,x1,x2
         for ylp=0 to (getsurfaceheight()-1)   step BitWidth
            Xpos=0
            for xlp=0 to (getsurfacewidth()/PixelStepX)-1   
               local ThisByte = (ThisByte+xlp) and 255
               copyrect  IMage_Frags,0,ThisByte,PixelStepX,ThisByte+1,Screen, Xpos,Ylp
               Xpos+=PixelStepX
            next
            if BitWidth>0
               X1 =0
               X2= getSurfaceWidth()
               local copyrow
               for copyrow =1 to BitWidth
                     copyrect screen,x1,ylp,x2,ylp+1,screen,0,ylp+copyrow                     
               
               next
            endif   
         next
         unlockbuffer

      rendertoscreen
      drawimage screen,0,0,false   
//      drawimage Image_Frags,600,0,false
   
      text 10,10, "Channel:"+str$(ThisByte)
      
      sync

   loop


[/pbcode]