 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
weak
Joined: 13 Jan 2005 Posts: 114 Location: Vienna, Austria
|
Posted: Wed Jun 15, 2005 1:01 am Post subject: screenshot snippet |
|
|
just made a function to grab the psp's framebuffer and write a screenshot to memory stick (as 24 bit bmp file). thought some of you may have some use for it.
i was just looking to make it work, feel free to improve it ;)
| Code: |
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);
|
here are two screenshots from our current project (just for illustration ;))
greetz, weak |
|
| Back to top |
|
 |
cable16
Joined: 22 Mar 2005 Posts: 22
|
Posted: Wed Jun 15, 2005 1:52 am Post subject: |
|
|
| that game looks quite nice :) |
|
| Back to top |
|
 |
Guest
|
Posted: Wed Jun 15, 2005 2:26 am Post subject: |
|
|
This is fantastic!
Keep in mind one real good use for this ...
Say you make a game. And you want to make a cool splash screen with a little running animation, just like the commercial PSP games ?
Use this method while running a special "debug" version of the program to save every X frames to the memory stick...
THEN
Distill the frames into a movie of the proper size, and merge back into your EBOOT.PBP file, with your splash screen.
Voila! |
|
| Back to top |
|
 |
weak
Joined: 13 Jan 2005 Posts: 114 Location: Vienna, Austria
|
Posted: Wed Jun 15, 2005 2:32 am Post subject: |
|
|
thx a lot! credits go to pimpot who made the artwork. i'm just writing the code ;)
i'll grab a small ingame movie soon if someone's interested. demo's coming too :) |
|
| Back to top |
|
 |
Squall333
Joined: 28 Apr 2005 Posts: 91
|
Posted: Wed Jun 15, 2005 3:54 am Post subject: |
|
|
| This must be good iv never seen gorim so excited |
|
| Back to top |
|
 |
Guest
|
Posted: Wed Jun 15, 2005 3:56 am Post subject: |
|
|
| Squall333 wrote: | | This must be good iv never seen gorim so excited |
Hehe ;)
Well I was gearing up to port a favorite game and been thinking about the splashscreen issue. Saved me some effort. ;) |
|
| Back to top |
|
 |
laxer3a
Joined: 11 May 2005 Posts: 23
|
Posted: Wed Jun 15, 2005 4:04 am Post subject: |
|
|
Hey weak,
You could improve the quality of the screenshots by using 32 items lookup table and promote each 5 bit component into 8 bit correctly (normalize) :
For the moment your whites are not white :-P
To create the table, just do (n*255)/31 for each value between 0 and 31.
Still quite usefull anyway.. thats cool ! |
|
| Back to top |
|
 |
numchuckskills
Joined: 04 May 2005 Posts: 35
|
Posted: Mon Jun 27, 2005 4:07 am Post subject: |
|
|
im a n00b... where do i throw this code to make it work?
thanks for your patience in advance... _________________ Not with a bang, but a whisper.
This is the way the world ends. |
|
| Back to top |
|
 |
Shine
Joined: 03 Dec 2004 Posts: 728 Location: Germany
|
|
| Back to top |
|
 |
Yoshihiro

Joined: 14 May 2005 Posts: 12
|
Posted: Mon Jun 27, 2005 7:43 am Post subject: Re: screenshot snippet |
|
|
| weak wrote: | just made a function to grab the psp's framebuffer and write a screenshot to memory stick (as 24 bit bmp file). thought some of you may have some use for it.
i was just looking to make it work, feel free to improve it ;)
| Code: |
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);
|
here are two screenshots from our current project (just for illustration ;))
greetz, weak |
Weak after when you have the new psptoolchain you can use my simple code for make 2000 screenshot very easy :=) .
| Code: |
int ScrenshotGen()
{
int fd;
char filename[56];
for(int i=0; i<2000; i++)
{
sprintf(filename, "ms0:/psp/game/Screenshot/screenshot%03d.bmp", i);
fd = sceIoOpen(filename,O_RDONLY);
if(fd < 0)
{
break;
}
sceIoClose(fd);
}
//Your string for make screenshot
YourScrenshotCode( filename);
return 0;
}
|
_________________
.jpg) |
|
| Back to top |
|
 |
sq377

Joined: 11 Apr 2005 Posts: 87
|
Posted: Mon Jun 27, 2005 2:01 pm Post subject: |
|
|
| I believe this has been included in the snes emulator.... Sort of. When you save your state, it takes a screenshot and saves the thumbnail. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|