GernotFrisch
Member
- Joined
- Jan 2, 2007
- Messages
- 445
I have some code to read from the back buffer, which works perfectly on windows debug version. However on the GP2X it seems that it skips every other line and reads a rectangle that's twice as big as the one I specified, but scaled by 1/2 in vertical.
Here's the code:
	
	
	
		
gl_malloc returns a mmap'ed memory from the upper 32 MB (mmuhack). The Screen.getColorBuffer is also in this memory space.
The graphic I am grabbing from looks correct. If I load an image into my sprite class, it works, too. But grabbed images are scaled by 1/2 in vertical, but the do have the correct size. I mean: I grab 32x32, and it returns me a grab of 32x64 scaled to 32x32.
Any ideas what this might be?
				
			Here's the code:
		Code:
	
		unsigned long scanline = Screen.getWidth();
	Buffer = (unsigned short*)gl_malloc(Width*Height*sizeof(unsigned short)); //memset(Buffer, 0, Width*Height*2);
	register unsigned short* pScreen = (unsigned short*)Screen.getColorBuffer();
	register unsigned short* pBuf = Buffer;
	for(y = ClipY; y < ClipHeight; y++)
	{
		for(x = ClipX; x < ClipWidth; x++)
		{
			*pBuf++ = *pScreen++;
		}
		pBuf-=ClipWidth;
		pBuf+=Width;
		pScreen-=ClipWidth;
		pScreen+=scanline;
	}gl_malloc returns a mmap'ed memory from the upper 32 MB (mmuhack). The Screen.getColorBuffer is also in this memory space.
The graphic I am grabbing from looks correct. If I load an image into my sprite class, it works, too. But grabbed images are scaled by 1/2 in vertical, but the do have the correct size. I mean: I grab 32x32, and it returns me a grab of 32x64 scaled to 32x32.
Any ideas what this might be?
 
	
 
 
		 
 
		 
 
		 
 
		