GP32 How To Save Screen As A 8bit Bmp Files


yaouank

Still Fresh
Joined
Mar 26, 2003
Messages
15
Hi,

Is there any SDK or source code already typed and tested to save the 8bits screen and the palette of the gp32 as a 8bits bmp file ?

Or do I have to do it myself ? (and freely publish it once done, of course)

Thank you.
 
yaouank posted on Feb 21 2005 at 06:10 PM said:
Hi,

Is there any SDK or source code already typed and tested to save the 8bits screen and the palette of the gp32 as a 8bits bmp file ?

Or do I have to do it myself ? (and freely publish it once done, of course)

Thank you.

Which SDK are you using?

EDIT: Nevermind I checked and I only have code to save a 16-bit BMP. It is pretty easy to save a BMP though. Just make sure that you end all the lines on a 4 byte DWORD. (Although this should not be an issue if you are saving the whole framebuffer.)

If you run into any trouble I would be glad to help as I spent a lot time loading and saving BMP's while developing gpPaint.
 
Last edited by a moderator:
Dalto posted on Feb 22 2005 at 01:59 AM said:
Which SDK are you using?

EDIT: Nevermind I checked and I only have code to save a 16-bit BMP. It is pretty easy to save a BMP though. Just make sure that you end all the lines on a 4 byte DWORD. (Although this should not be an issue if you are saving the whole framebuffer.)

If you run into any trouble I would be glad to help as I spent a lot time loading and saving BMP's while developing gpPaint.

I'm using the god old gp32 sdk (downloaded from the download section of http://www.devkit.tk/ )

Ok, I will try to do the biggest part myself and may contact you when it won't work.
 
Last edited by a moderator:
Code:
//////////////////////////////////////////////////////////////////////////////////////
// void capturescreen16(GPDRAWSURFACE *gpdraws, char *path)
// save the screen gpdraws in path (24 bpp bmp) (for 16 bits mode)
//////////////////////////////////////////////////////////////////////////////////////

unsigned char bmp[320*240*3];

const unsigned char header[54] = {
66, 77, 54, 132, 3, 0, 0, 0, 0, 0, 54, 0, 0, 0, 40, 0, 
0, 0, 64, 1, 0, 0, 240, 0, 0, 0, 1, 0, 24, 0, 0, 0, 
0, 0, 0, 132, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0
};

void capturescreen16(GPDRAWSURFACE *gpdraws, char *path)
{
 F_HANDLE f2;
 unsigned short *image;
 int x, y;
 unsigned char r, v, b, i;


 image = (unsigned short*)gpdraws->ptbuffer;


 GpFileCreate(path, ALWAYS_CREATE, &f2);

 GpFileWrite(f2, &header, 54);


 for (x = 0; x < 320; x++)
  for (y = 0; y < 240; y++)
  {
   r = (image[y+(x*240)] >> 1) * 8;
   v = (image[y+(x*240)] >> 6) * 8;
   b = (image[y+(x*240)] >> 11) * 8;

   i = (image[y+(x*240)] << 7) >> 7;

   if (i == 1) // highlight bit ??
   {
    if (r < 255) r++;
    if (v < 255) v++;
    if (b < 255) b++;
   }

   bmp[(x+y*320)*3] = r;
   bmp[(x+y*320)*3+1] = v;
   bmp[(x+y*320)*3+2] = b;
  }

  GpFileWrite(f2, &bmp, sizeof(bmp));


  GpFileClose(f2);
}


//////////////////////////////////////////////////////////////////////////////////////
// void capturescreen8(GPDRAWSURFACE *gpdraws, char *path)
// save the screen gpdraws in path (24 bpp bmp) (for 8 bits mode)
//////////////////////////////////////////////////////////////////////////////////////

unsigned char bmp[320*240*3];

const unsigned char header[54] = {
66, 77, 54, 132, 3, 0, 0, 0, 0, 0, 54, 0, 0, 0, 40, 0, 
0, 0, 64, 1, 0, 0, 240, 0, 0, 0, 1, 0, 24, 0, 0, 0, 
0, 0, 0, 132, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0
};

void capturescreen8(GPDRAWSURFACE *gpdraws, char *path)
{
 F_HANDLE f2;
 unsigned char *image;
 int x, y;
 unsigned char r, v, b, i;
 long *pal = (long *)0x14a00400;

 image = (unsigned char*)gpdraws->ptbuffer;


 GpFileCreate(path, ALWAYS_CREATE, &f2);

 GpFileWrite(f2, &header, 54);


 for (x = 0; x < 320; x++)
  for (y = 0; y < 240; y++)
  {
   r = (pal[image[y+(x*240)]] >> 1) * 8;
   v = (pal[image[y+(x*240)]] >> 6) * 8;
   b = (pal[image[y+(x*240)]] >> 11) * 8;

   i = (pal[image[y+(x*240)]] << 7) >> 7;

   if (i == 1) // highlight bit ??
   {
    if (r < 255) r++;
    if (v < 255) v++;
    if (b < 255) b++;
   }

   bmp[(x+y*320)*3] = r;
   bmp[(x+y*320)*3+1] = v;
   bmp[(x+y*320)*3+2] = b;
  }

  GpFileWrite(f2, &bmp, sizeof(bmp));


  GpFileClose(f2);
}

why the hell do i put my code on my site..
 
Last edited by a moderator:
(si t'a besoin de code absolument pour enregistrer en 8 bits, je peux te le faire ca change quasiment rien, pour le site, je l'ai supprimé pour l'instant en fait, mais t'aurai pu le chopper avant :p a+)
 
Thank aquafish. It works (I never doubt of that ;) ) !
telecran.fxe

00043896.BMP

[start] to save in GP:\GPMM\TELECRAN\
[joystick] and [A] to draw
[Shoulder] (several times) to erase

(yes I know, the naming of the picture is weird, generated by GpRand() )
 
Back
Top