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.
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 ?
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 ?