i was just looking to make it work, feel free to improve it ;)
Code: Select all
unsigned char bmpHeader24[] = { 0x42, 0x4d, 0x38, 0xfa, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0xe0, 0x01, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00, 0x01, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x0b, 0x00, 0x00, 0x12, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
unsigned char buffer[SCREEN_WIDTH*3];
unsigned char r,g,b;
int bufferIndex = 0;
unsigned short p;
file = sceIoOpen(savePath,O_CREAT | O_TRUNC | O_RDWR, 0777); // savePath should hold the path to your file
// write bmp header
sceIoWrite(file,bmpHeader24,54);
// write bmp data
vptr0 = pgGetVramAddr(0,271); // you can find this function in NEM's sources
for(i=0; i<272; i++)
{
vptr=vptr0;
for(e=0; e<480; e++)
{
p = *(unsigned short *)vptr;
r = (p<<3)&0xf8;
g = (p>>2)&0xf8;
b = (p>>7)&0xf8;
buffer[bufferIndex] = b;
bufferIndex++;
buffer[bufferIndex] = g;
bufferIndex++;
buffer[bufferIndex] = r;
bufferIndex++;
vptr+=PIXELSIZE*2;
}
// write chunk
sceIoWrite(file,buffer,SCREEN_WIDTH*3);
bufferIndex=0;
vptr0-=LINESIZE*2;
}
// bmp end
unsigned char end[] = { 0x00, 0x00 };
sceIoWrite(file,end,2);
sceIoClose(file);
greetz, weak