pixmap copying pixels from loaded to static

BlitzMax Forums/BlitzMax Beginners Area/pixmap copying pixels from loaded to static

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.

I have a function where I make a static pixmap and I am trying to make a function where I can change pixels in that from a loaded pixmap.

Function zgPixmapCreate:TPixmap( width, height )
	Local pmap:TPixmap = New TPixmap
	pmap.pixels = MemAlloc( width * height * 4 )
	pmap.width = width
	pmap.height = height
	pmap.pitch = width * 4
	pmap.format = 6
	pmap.capacity = -1
	Return pmap
End Function

Function zgCopyRect( source:TPixmap, target:TPixmap, x, y, width, height, tx, ty )
	For Local yy = 0 To height-1
		For Local xx = 0 To width-1
			Local src = source.pitch * ( yy + y ) + ( xx + x ) * 4
			Local des = target.pitch * ( yy + ty ) + ( xx + tx ) * 4
			target.pixels[des] = source.pixels[src]
			target.pixels[des+1] = source.pixels[src+1]
			target.pixels[des+2] = source.pixels[src+2]
			target.pixels[des+3] = source.pixels[src+3]
		Next
	Next
End Function


The above makes a pixmap which is set up using RGBA8888 format with 4 bytes per pixel. It works just fine when using two pixmaps that I have made with the first function, but when using a loaded pixmap as the source it copy over garbage pixel data.

I have tried to figure out how the format of the pixmap that gets loaded with loadpixmap command is set up. But even if I do a convert to RGBA8888 it doesn't work.

How would you copy pixels from a loaded pixmap to a static ?