forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

screenshot-homebrew related questions

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Fejwin



Joined: 19 Sep 2007
Posts: 12

PostPosted: Wed Sep 26, 2007 4:12 am    Post subject: screenshot-homebrew related questions Reply with quote

I'm looking for the source code of a program that runs in the background and can make screenshots of a game while playing.
I know there are several of these programms on the net. I would like to study the source code of the simpliest one to understand how it functions.
I will be very greatful if someone can post that here ))

Thaks in advance!

Fejwin

EDIT:
Most interesting part is, how do I let a program run in the background while other things (like playing games, listen to music etc.) are going on?
_________________
hey there


Last edited by Fejwin on Wed Sep 26, 2007 5:28 am; edited 2 times in total
Back to top
View user's profile Send private message
califrag



Joined: 04 Apr 2007
Posts: 30

PostPosted: Wed Sep 26, 2007 4:56 am    Post subject: Reply with quote

i haven't tried this myself but this function in the graphics.c/graphics.h seems like it may work - not sure how fast it may be.


/**
* Save an image or the screen in PNG or JPEG format (depends on the filename suffix).
*
* @pre filename != NULL
* @param filename - filename of the PNG image
* @param data - start of Color type pixel data (can be getVramDisplayBuffer())
* @param width - logical width of the image or SCREEN_WIDTH
* @param height - height of the image or SCREEN_HEIGHT
* @param lineSize - physical width of the image or PSP_LINE_SIZE
* @param saveAlpha - if 0, image is saved without alpha channel
*/
extern void saveImage(const char* filename, Color* data, int width, int height, int lineSize, int saveAlpha);
Back to top
View user's profile Send private message
Fejwin



Joined: 19 Sep 2007
Posts: 12

PostPosted: Wed Sep 26, 2007 5:10 am    Post subject: Reply with quote

@califrag:
Thanks a lot for help!!
I've just found that little code here in the forum, it has a bit more details in it:
Code:
void saveScreen() {
         int posX;
         int posY;
         Color pixel;
         Color* vram = getVramDisplayBuffer();
         Image* screenShot;
         screenShot = createImage(480,272);
         for (posY=0; posY<272; posY++) {
         for(posX=0; posX<480; posX++) {
         pixel = vram[PSP_LINE_SIZE * posY + posX];
         putPixelImage(pixel,posX,posY,screenShot);
         }
         }
         saveImage("ms0:/Snapshot.png",screenShot->data,480,272,PSP_LINE_SIZE,0);
         freeImage(screenShot);
}

I think it will do the screen.

But I have some questions about "pixel = vram[PSP_LINE_SIZE * posY + posX];"
How does "PSP_LINE_SIZE * posY + posX" navigate to the right pixel?! It just looks like it multiplicates PSP_LINE_SIZE and posY and then counts everything together... o_O
Does vram[] just save the momentary color of target pixel into the pixel variable? Can I assign a color-index of my choice to each pixel? Or first get the color-index, then check which color it contains and if it has not the color which I want to keep, can I asign it an other one before writing it into ScreenShot?

The other question still remains: How do I let that function loop while doing other things on PSP?

EDIT:
AH!! XD I just got it!! It has to be that getVramDisplayBuffer() uses only one value to navigate to pixels!! AND its going each line from left to right and just jumps back and one line down when it reaches the last pixel of one line ^^ tricky, I admit that ))

Still:
Can I asign my wished color-index to a pixel before writing into ScreenShot?
And how do I let it loop in the background??
_________________
hey there
Back to top
View user's profile Send private message
Art



Joined: 09 Nov 2005
Posts: 647

PostPosted: Wed Sep 26, 2007 11:21 am    Post subject: Reply with quote

The answer is most likely yes you can.
It might help to explain exactly what you're doing.
Overlaying text/sprite to the screenshot?
Back to top
View user's profile Send private message
Smong



Joined: 04 Sep 2007
Posts: 82

PostPosted: Thu Sep 27, 2007 1:38 am    Post subject: Reply with quote

I've edited the function to include an example of editing the pixel colors:
Code:
void saveScreen()
{
   int posX, posY;
   Color pixel;
   Color* vram = getVramDisplayBuffer();
   Image* screenShot;
   screenShot = createImage(480, 272);
   for (posY = 0; posY < 272; posY++)
   {
      for (posX = 0; posX < 480; posX++)
      {
         pixel = vram[posX + posY * PSP_LINE_SIZE];
         
         /* change pixel here, assuming 8888 format and Color is a 32-bit int,
          * then pixel = 0xAABBGGRR with AA set to ff=visible, 00=invisible. */
         
         /* this will change all blue pixels to red */
         if ((pixel >> 16) & 0xff == 255 &&
            (pixel >> 8) & 0xff == 0 &&
            (pixel) & 0xff == 0)
         {
            pixel = 0xff0000ff;
         }
         
         /* this will add a green line down the left side */
         if (posX == 0)
            pixel = 0xff00ff00;
         
         putPixelImage(pixel, posX, posY, screenShot);
      }
   }
   saveImage("ms0:/Snapshot.png", screenShot->data, 480, 272, PSP_LINE_SIZE, 0);
   freeImage(screenShot);
}

_________________
(+[__]%)
Back to top
View user's profile Send private message
Fejwin



Joined: 19 Sep 2007
Posts: 12

PostPosted: Thu Sep 27, 2007 4:47 pm    Post subject: Reply with quote

@Smong:
Wow, thanks for that extansion!!
I Think if I study this 8888 format I will be able to change any pixel in any color ) THX
(btw. is this code 3.xx kernel adopted?)

Now the only one quenstion remains:
How can I let my program run in the background and make screenshots (without saving them unless a condition occures) while I'm doing other things on the PSP?? ^^

An answer to this question will get me further really )) Hope someone can help.
_________________
hey there
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
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