Mirror Test

BlitzMax Forums/BlitzMax Programming/Mirror Test

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.

In my next production I need a routine that can mirror a TImage with all its possible frames. Since there's (as far as I know) no more ImageBuffer available, I had to figure something out myself. I went diggin' into the sources of the modules. I really wonder if they couldn't be made any simpler, so it took a lot of digesting, and I still don't think I've found all I need to know.

In the end I came up with this source to do the trick:
Strict

Rem Mirror
	
	Worked by these persons:
	Tricrokra	June 3 2005		Basis source
	
End Rem

Function Mirror:TImage(Img:TImage,Frames=1)
Local Ret:TImage
Local Ak,XX,YY
Ret = CreateImage(ImageWidth(Img),ImageHeight(Img),Frames)
For Ak=0 To Frames-1
	Ret.PixMaps[Ak] = CreatePixmap(ImageWidth(Img),ImageHeight(Img),PF_BGRA8888)
	For XX=0 To ImageWidth(Img)-1
		For YY=0 To ImageHeight(Img)-1
			WritePixel Ret.PixMaps[Ak],(ImageWidth(Img)-1)-XX,YY,ReadPixel(Img.PixMaps[Ak],XX,YY)
			Next
		Next
	Next
Ret.mask_r = Img.mask_r
Ret.mask_g = Img.mask_g
Ret.mask_b = Img.mask_b
Return Ret
End Function


The first tests had good results, but I wonder if this routine would cover everything that needs to be covered, or if I should code it diffrently. Anyway, the routine appears to be working, perfectly, at least that's what the eyes indicate, and that's what matters for me for the time being.

If you think this routine should be altered somehow, then let me know. If you think this routine is perfect the way it is, you're free to use it if you need it.