Flip Image

Blitz3D Forums/Blitz3D Programming/Flip Image

For y=0 To h-1
    For x=0 To w-1
	pix = ReadPixelFast(x,y,ImageBuffer(img))
	If horz=1 And verz=0 Then WritePixelFast(w-x-1,y,pix,ImageBuffer(newimage))
	If horz=0 And verz=1 Then WritePixelFast(x,h-y-1,pix,ImageBuffer(newimage))
	If horz=1 And verz=1 Then WritePixelFast(w-x-1,h-y-1,pix,ImageBuffer(newimage))
    Next
Next

;or
h=h-1 : w=w-1

For y=0 To h
    For x=0 To w
	pix = ReadPixelFast(x,y,ImageBuffer(img))
	If horz=1 And verz=0 Then WritePixelFast(w-x,y,pix,ImageBuffer(newimage))
	If horz=0 And verz=1 Then WritePixelFast(x,h-y,pix,ImageBuffer(newimage))
	If horz=1 And verz=1 Then WritePixelFast(w-x,h-y,pix,ImageBuffer(newimage))
    Next		
Next

;or

Function FlipImg(infile$,outfile$,horz, verz)
	Local img = LoadImage(infile$)
	
	TFormFilter False
	ScaleImage img,1-2*(horz=True),1-2*(verz=True)
	
	SaveBuffer (ImageBuffer(img),outfile$)
	
	FreeImage img
	
End Function