Hi,
I usually have no problems whatsoever using Remote Zoomin to get screenshots from my ipaq over a network link.
However, I have just tried to get a screen shot of my first GAPI game and all I get is a blank image (all white). It works ok for everything else, gdi etc. I have even tried pausing the game. It looks like it is downloading the image ok but then displays this white image.
Has anyone else had this problem or know of fix
Thanks in advance
Bad
That will happen with ALL screengrab methods which just grab the gdi screen, which is blank under GAPI.
The best solution is just to write your own 'save as bmp' code, put it in your game, and it will work well.
This is just a guess, but I would think that GDI has in internal surface that acts like a back buffer that it copies to the display memory. Since your app has circumvented GDI and is drawing directly into display memory, the data you're drawing never gets into GDI's back buffer.
One fix would be to write your own screen dump routine that would save it to a file on the PocketPC which you could then retrieve through ActiveSync's file explorer.
You need a GAPI-based capture program. Larry Bank has such a program for sale called "Virtual_CE". It can be found at
http://www.bitbanksoftware.com/ce/. East
hey,
i had this code floating around, it does pretty much exactly what you need, but it should be optimized a lil bit

- Code:
void SaveBMP( LPTSTR lpFileName, BYTE * buf, UINT width, UINT height)
{
short res1=0;
short res2=0;
long pixoff=54;
long compression=0;
long cmpsize=0;
long colors=0;
long impcol=0;
char m1='B';
char m2='M';
char filePath[MAX_PATH];
wcstombs( filePath, lpFileName, MAX_PATH );
DWORD widthDW = WIDTHBYTES(width * 24);
long bmfsize=sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) +
widthDW * height;
long byteswritten=0;
BITMAPINFOHEADER header;
header.biSize=40; // header size
header.biWidth=width;
header.biHeight=height;
header.biPlanes=1;
header.biBitCount=24; // RGB encoded, 24 bit
header.biCompression=BI_RGB; // no compression
header.biSizeImage=0;
header.biXPelsPerMeter=0;
header.biYPelsPerMeter=0;
header.biClrUsed=0;
header.biClrImportant=0;
FILE *fp;
fp=fopen( filePath,"wb");
if (fp==NULL) {
return;
}
// should probably check for write errors here...
fwrite((BYTE *)&(m1),1,1,fp); byteswritten+=1;
fwrite((BYTE *)&(m2),1,1,fp); byteswritten+=1;
fwrite((long *)&(bmfsize),4,1,fp); byteswritten+=4;
fwrite((int *)&(res1),2,1,fp); byteswritten+=2;
fwrite((int *)&(res2),2,1,fp); byteswritten+=2;
fwrite((long *)&(pixoff),4,1,fp); byteswritten+=4;
fwrite((BITMAPINFOHEADER *)&header,sizeof(BITMAPINFOHEADER),1,fp);
byteswritten+=sizeof(BITMAPINFOHEADER);
long row=0;
long rowidx;
long row_size;
row_size=header.biWidth*3;
long rc;
for (row=0;row<header.biHeight;row++) {
rowidx=(long unsigned)row*row_size;
// write a row
rc=fwrite((void *)(buf+rowidx),row_size,1,fp);
if (rc!=1)
{
break;
}
byteswritten+=row_size;
// pad to DWORD
for (DWORD count=row_size;count<widthDW;count++)
{
char dummy=0;
fwrite(&dummy,1,1,fp);
byteswritten++;
}
}
fclose(fp);
}
cryo
This sounds like a similar problem to what people run into with DirectX on win32. If I recall the trick was to create a DIB section directly off the main screen and then use GDI to dump it to a BMP. Ofcourse, with GAPI you could go one step lower and just get the pointer to the screen and dump it to a BMP fairly easily too.
-Hosed
Thank you all very much.
What else can I say? Only on PocketMatrix do I get the full explanation of what the problem three different solutions, including the source code.
Hope I can help you guys out sometime

Thanks again
Bad
Cryo,
Thanks for the code, on the line :-
DWORD widthDW = WIDTHBYTES(width * 24);
What did you have WIDTHBYTES defined as?
Thanks in advance
Bad
Hosed,
This sounds like a similar problem to what people run into with DirectX on win32. If I recall the trick was to create a DIB section directly off the main screen and then use GDI to dump it to a BMP. Ofcourse, with GAPI you could go one step lower and just get the pointer to the screen and dump it to a BMP fairly easily too.
-Hosed
the problem with that approach is that wince does not have support for the getDIBBits function. It is still possible, but as you say its easier to just dump the bits into a BMP file if youre using GAPI.
cryo
The remote zoomin for the HPC 720 gets the GAPI just fine. Maybe that's because of the way the GAPI is instituted on the HPC.
Cryo,
I've got this code into my game library and it has compiled cleanly. But like Dan says "Compiling is only the beginning!"
Anyway, I pass it my display pointer, returned from Gapi and it creates an odd image. Is this how I am supposed to use it? What device do you use it on?
Thanks in advance
Bad
The code posted isn't doing a conversion from 16-bpp to 24-bpp as it writes the bitmap pixel data to the file. I don't know how that code would have ever worked on a Pocket PC if you fed it the buffer pointer returned from GXBeginDraw. Cryo?
yes, you can't just pass your (unsigned short*) GAPI backbuffer to this rutine, it expects an RGB array with each entry being 24pbb. Since such an array is device dependent (or better: display dependent), you will have to construct it with your settings before calling SaveBMP, using the ffFormat member of the GXDisplayProperties struct returned by a call to GXGetDisplayProperties.
Gimme time until tomorrow, then i will post a "standalone" version of the rutine.
cryo
Thanks Cryo, I'll try and wait patiently

BadBazza,
sorry for the delay. Here is some (untested!) code that takes an unsigned short pointer, so you can pass it your back buffer. It might be necessary to adapt the shifting to your devices pixel format and it still can be optimized *a lot*. :)
- Code:
void SaveBMP( WCHAR *lpFileName, unsigned short * buf, UINT width, UINT height )
{
short res1=0;
short res2=0;
long pixoff=54;
long compression=0;
long cmpsize=0;
long colors=0;
long impcol=0;
char m1='B';
char m2='M';
char filePath[MAX_PATH];
wcstombs( filePath, lpFileName, MAX_PATH );
DWORD widthDW = WIDTHBYTES(width * 24);
long bmfsize=sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + widthDW * height;
long byteswritten=0;
BITMAPINFOHEADER header;
header.biSize=40; // header size
header.biWidth=width;
header.biHeight=height;
header.biPlanes=1;
header.biBitCount=24; // RGB encoded, 24 bit
header.biCompression=BI_RGB; // no compression
header.biSizeImage=0;
header.biXPelsPerMeter=0;
header.biYPelsPerMeter=0;
header.biClrUsed=0;
header.biClrImportant=0;
FILE *fp;
fp=fopen( filePath,"wb");
if (fp==NULL) {
return;
}
// should probably check for write errors here...
fwrite((BYTE *)&(m1),1,1,fp); byteswritten+=1;
fwrite((BYTE *)&(m2),1,1,fp); byteswritten+=1;
fwrite((long *)&(bmfsize),4,1,fp); byteswritten+=4;
fwrite((int *)&(res1),2,1,fp); byteswritten+=2;
fwrite((int *)&(res2),2,1,fp); byteswritten+=2;
fwrite((long *)&(pixoff),4,1,fp); byteswritten+=4;
fwrite((BITMAPINFOHEADER *)&header,sizeof(BITMAPINFOHEADER),1,fp);
byteswritten+=sizeof(BITMAPINFOHEADER);
long row=0;
long rowidx;
long row_size;
row_size=header.biWidth*3;
long rc;
typedef struct sRGB
{
BYTE r;
BYTE g;
BYTE b;
} sRGB;
for( row=header.biHeight-1; row>0; row-- )
{
rowidx = row*header.biWidth;
// write a row
for( int i=0; i<header.biWidth; i++ )
{
sRGB rgb;
memset( (sRGB*)&rgb, 0, sizeof(sRGB ) );
rgb.r = (BYTE)(buf[rowidx+i] >> 11);
rgb.g = (BYTE)((buf[rowidx+i] << 5 ) >> 10);
rgb.b = (BYTE)((buf[rowidx+i] << 11 ) >> 11 );
rc = fwrite( (sRGB*)&rgb, sizeof(sRGB), 1, fp );
}
byteswritten+=row_size;
// pad to DWORD
for (DWORD count=row_size;count<widthDW;count++)
{
char dummy=0;
fwrite(&dummy,1,1,fp);
byteswritten++;
}
}
fclose(fp);
}
cryo
Cryo,
Thanks for this, I will try this out tonight and let you know.
Regards
Bad
Cryo,
I've tried your code and as you said it does require some work on the color conversion, I look into this. In the meantime if you or anybody else reading this knows what the color conversion should be for an iPaq 3630 please let me know.
Also Cryo, what device is this designed for?
Thanks in advance
Bad
BadBazza,
Check your messages.