ASCII MoviePlayer

Miscellaneous Forums/Blitz Showcase/ASCII MoviePlayer

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

This one is using bitmaps. The images "buffer" and "asciiimage" are not used anymore. Instead the movie is drawn to the backbuffer, readpixel will then be stored in an array "rgb()", to allow readpixelfast with a locked backbuffer and Drawimage with an unlocked backbuffer.

On my old terminal it runs at ~double speed.
AppTitle "ASCII MoviePlayer - F1 for FPS"
Graphics 640, 480, 32, 2
SetBuffer BackBuffer()

Global FPS#, FPSTime
Global chars$ = " .,:`;'^" + Chr(34) + "<>\-/_!~=?)(|t+i7{j}lv]%[1cf32Jr$CuIyz9o6wTna5sk&VY40LO8mG*hexSgApqbZdUPQFDXKW#RNEHBM@"

Global file$ = "C:\WINDOWS\Desktop\ttttt\genom\content\genom_trailer.rm";RequestFile("", "avi")
Global movie% = OpenMovie(file$)

Global fowi=StringWidth("W")
Global fohe=StringHeight("§")
Color 255,0,0
Dim ascii_bmp(255)
Dim rgb(GraphicsWidth(),GraphicsHeight())
For i = 0 To 255
 ascii_bmp(i)=CreateImage(fowi,fohe)
 SetBuffer ImageBuffer(ascii_bmp(i))
 Text 0,0,Chr$(i)
 MaskImage ascii_bmp(i),255,0,0
Next

; -------------------------------
While Not KeyHit(1)

 DrawMovie(movie%, 0, 0, GraphicsWidth(),GraphicsHeight())
 ImageToChars()

 If KeyDown(59) Then 
  Color 255, 255, 255
  Text 5, 5, "FPS: " + Int(FPS)
 EndIf

 Flip
 CountFPS()
Wend
End




Function ImageToChars()
 Local w% = 0, char$ = "", argb%, red%, green%, blue%
 w=fowi

 SetBuffer BackBuffer()
 LockBuffer BackBuffer()
 For y = 0 To ((GraphicsHeight()-1) / fohe)
  For x = 0 To (GraphicsWidth() / w%) - 1
   rgb(x,y) = ReadPixel((x + .5) * w%, (y + .5) * fohe)
  Next
 Next
 UnlockBuffer BackBuffer()

 For y = 0 To ((GraphicsHeight()-1) / fohe)
  For x = 0 To (GraphicsWidth() / w%) - 1
   argb%=rgb(x,y)
   red% = (argb Shr 16) And $FF
   green% = (argb Shr 8) And $FF
   blue% = argb And $FF
   col# = (Float red + green + blue) / (765)

   Color red, green, blue
   Rect x*w,y*fohe,fowi,fohe,1

   char$ = Mid$(chars$, (Len(chars$) - 1) * col# + 1, 1)
   DrawImage ascii_bmp(Asc(char$)), x% * w%, y% * fohe
  Next
 Next
End Function


Function CountFPS()
 FPS# = 1000.0 / (MilliSecs() - fpstime)
 FPSTime = MilliSecs()
End Function