SuperStrict

Import pantson.yuv

Local tmp:TBank
Local ypoint:Byte Ptr
Local upoint:Byte Ptr
Local vpoint:Byte Ptr
Local p:TPixmap
Local m:Int,i:Int

' an example YUV data packet
' WIDTH, HEIGHT and FACTOR must be specified or funny results may occour
' these values were obtained fomr the webiste about the example stream
' http://www.efg2.com/Lab/Graphics/Colors/YUV.htm

' A YVU9 stream example
tmp = LoadBank("YVU9.Stream")
YUV_WIDTH = 352
YUV_HEIGHT = 288
YUV_FACTOR=4

' A YVU12 stream example
'tmp = LoadBank("YVU12.Stream")
'YUV_WIDTH = 352
'YUV_HEIGHT = 288
'YUV_FACTOR=2


' these point to areas within the above bank
ypoint = BankBuf(tmp)
upoint = ypoint + YUV_WIDTH*YUV_HEIGHT
vpoint = upoint + YUV_WIDTH*YUV_HEIGHT/YUV_FACTOR/YUV_FACTOR

' start graphics
Graphics(800,600,0)

' pixmap is created using width and height at least the size of the YUV values
' or strange results may occour as no error checking (to make it faster).
p = CreatePixmap(YUV_WIDTH,YUV_HEIGHT,PF_BGRA8888)

i= 0
m = MilliSecs()
While Not KeyDown(key_escape)
	' draw color pixmap (YUV)
	YUVdrawYUV(p,ypoint,upoint,vpoint)
	
	' draw black and white pixamp (Y = luminance)
	'YUVdrawY(p,ypoint)
	
	DrawPixmap p,0,0
	i:+1
	Flip
Wend
Print "frames per second = " + (i*1000)/(MilliSecs()-m)

SavePixmapJPeg p,"output.jpg"
End

