SuperStrict
Rem
bbdoc: YUV
EndRem
Module pantson.yuv

ModuleInfo "Version: 2.00"
ModuleInfo "Author: Richard Hanson"
ModuleInfo "Modserver: pantson"

Import BRL.Pixmap
Import "yuv.c"

Private

Extern
	Function _YUVinit:Byte Ptr()
	Function _YUVdrawYUV(pixmap:Byte Ptr,width:Int,height:Int,Y:Byte Ptr,U:Byte Ptr,V:Byte Ptr,ywidth:Int,yheight:Int,yfactor:Int)
	Function _YUVdrawY(pixmap:Byte Ptr,width:Int,height:Int,Y:Byte Ptr,ywidth:Int,yheight:Int)
End Extern


' =================================================

' based on this article
' http://www.efg2.com/Lab/Graphics/Colors/YUV.htm
' theory taken form webpage, no code has been used.

' see below copyright
' http://www.efg2.com/Lab/Copyright.htm

' =================================================

' setup
' create lookup tables.
_YUVinit()

Public
Global YUV_WIDTH:Int
Global YUV_HEIGHT:Int
Global YUV_FACTOR:Int

Rem
bbdoc: Draw a YUV data onto a pixmap. Y U V must be pointers to the YUV data. This will produce a color image.
returns: True
End Rem
Function YUVDrawYUV:Int(p:TPixmap,Y:Byte Ptr,U:Byte Ptr,V:Byte Ptr)
'	If p.format <> PF_STDFORMAT Then Return False
	
	_YUVdrawYUV(p.pixels,p.width,p.height,Y,U,V,YUV_WIDTH,YUV_HEIGHT,YUV_FACTOR)
	Return True
End Function

Rem
bbdoc: Draw a YUV data onto a pixmap. Y must be a pointer to the Y data. This will produce a greyscale image.
returns: True
End Rem
Function YUVdrawY:Int(p:TPixmap,Y:Byte Ptr)
'	If p.format <> PF_STDFORMAT Then Return False

	_YUVdrawY(p.pixels,p.width,p.height,Y,YUV_WIDTH,YUV_HEIGHT)
	Return True
End Function

