Problems with screenshot code.

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Panajev2001a
Posts: 100
Joined: Sat Aug 20, 2005 3:25 am

Post by Panajev2001a »

My frame-buffer set-up is this:

Code: Select all

	sceGuDrawBuffer(GU_PSM_8888,(void*)FRAME_BUFFER_1,BUF_WIDTH);
	sceGuDispBuffer(SCR_WIDTH,SCR_HEIGHT,(void*)FRAME_BUFFER_2,BUF_WIDTH);
The "initial" Draw Buffer when the application is initialized is at the beginning of VRAM and after that we have the Display Buffer and then the Z-buffer.

If in Vram32 (the pointer to the beginning of the frame-buffer) that address is returned (beginning of VRAM) then Vram32 should be pointing, since this function is called after the SwapBuffers() function, to the current Display Buffer (which is what was the Draw Buffer before we swapped the buffers, etc...).

We should still have the Vblank + 1 frame_time to save the image.
Panajev2001a
Posts: 100
Joined: Sat Aug 20, 2005 3:25 am

Post by Panajev2001a »

deleted...
Last edited by Panajev2001a on Sat Sep 03, 2005 1:53 am, edited 1 time in total.
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Post by Shine »

I'm sure you know that your malloc is still wrong :-)
Panajev2001a
Posts: 100
Joined: Sat Aug 20, 2005 3:25 am

Post by Panajev2001a »

publicity message: drink PanaCola.
Last edited by Panajev2001a on Sat Sep 03, 2005 1:54 am, edited 1 time in total.
Panajev2001a
Posts: 100
Joined: Sat Aug 20, 2005 3:25 am

Post by Panajev2001a »

yeah, malloc ... what a shitty hack I did... allocating chars for "%05d" that way... grumble.

Here:

EDIT: feck FREE and MALLOC (well in this spot)

Code: Select all

void screenshot(const char* filename)
{
		static int m_SS_Number = 0;
        u32* vram32;
        u16* vram16;
        int bufferwidth;
        int pixelformat;
        int unknown;
        int i, x, y;
        png_structp png_ptr;
        png_infop info_ptr;
        FILE* fp;
        u8* line;

		//char *  name =  NULL;
		
		//name = (char *) malloc ( strlen(filename) + 1 + 5 + 4 + 1);

                char name [strlen (filename) + 11] addr_align(16);

		sprintf(name, "%s_%05d.png", filename, m_SS_Number);
        
		fp = fopen((const char *)name, "wb");

        if (!fp) return;
        png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
        if (!png_ptr) return;
        info_ptr = png_create_info_struct(png_ptr);
        if (!info_ptr) {
                png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
                fclose(fp);
                return;
        }
        png_init_io(png_ptr, fp);
        png_set_IHDR(png_ptr, info_ptr, SCREEN_WIDTH, SCREEN_HEIGHT,
                8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE,
                PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
        png_write_info(png_ptr, info_ptr);
        line = (u8*) malloc(SCREEN_WIDTH * 3);
        sceDisplayWaitVblankStart();  // if framebuf was set with PSP_DISPLAY_SETBUF_NEXTFRAME, wait until it is changed
        sceDisplayGetFrameBuf((void**)&vram32, &bufferwidth, &pixelformat, &unknown);
        vram16 = (u16*) vram32;
        for &#40;y = 0; y < SCREEN_HEIGHT; y++&#41; &#123;
                for &#40;i = 0, x = 0; x < SCREEN_WIDTH; x++&#41; &#123;
                        u32 color = 0;
                        u8 r = 0, g = 0, b = 0;
                        switch &#40;pixelformat&#41; &#123;
                                case PSP_DISPLAY_PIXEL_FORMAT_565&#58;
                                        color = vram16&#91;x + y * bufferwidth&#93;;
                                        r = &#40;color & 0x1f&#41; << 3; 
                                        g = &#40;&#40;color >> 5&#41; & 0x3f&#41; << 2 ;
                                        b = &#40;&#40;color >> 11&#41; & 0x1f&#41; << 3 ;
                                        break;
                                case PSP_DISPLAY_PIXEL_FORMAT_5551&#58;
                                        color = vram16&#91;x + y * bufferwidth&#93;;
                                        r = &#40;color & 0x1f&#41; << 3; 
                                        g = &#40;&#40;color >> 5&#41; & 0x1f&#41; << 3 ;
                                        b = &#40;&#40;color >> 10&#41; & 0x1f&#41; << 3 ;
                                        break;
                                case PSP_DISPLAY_PIXEL_FORMAT_4444&#58;
                                        color = vram16&#91;x + y * bufferwidth&#93;;
                                        r = &#40;color & 0xf&#41; << 4; 
                                        g = &#40;&#40;color >> 4&#41; & 0xf&#41; << 4 ;
                                        b = &#40;&#40;color >> 8&#41; & 0xf&#41; << 4 ;
                                        break;
                                case PSP_DISPLAY_PIXEL_FORMAT_8888&#58;
                                        color = vram32&#91;x + y * bufferwidth&#93;;
                                        r = color & 0xff; 
                                        g = &#40;color >> 8&#41; & 0xff;
                                        b = &#40;color >> 16&#41; & 0xff;
                                        break;
                        &#125;
                        line&#91;i++&#93; = r;
                        line&#91;i++&#93; = g;
                        line&#91;i++&#93; = b;
                &#125;
                png_write_row&#40;png_ptr, line&#41;;
        &#125;
        free&#40;line&#41;;
        png_write_end&#40;png_ptr, info_ptr&#41;;
        png_destroy_write_struct&#40;&png_ptr, &#40;png_infopp&#41;NULL&#41;;
        fclose&#40;fp&#41;;

		//if &#40;name != NULL&#41; &#123;
			
			//free &#40;name&#41;;

		//&#125;

		m_SS_Number++;
&#125;
of course 1 + 5 + 4 + 1 = 11 ;).

1 for the '_' char.

5 for the 5 digits of the integer value.

4 for the ".png" portion of the string.

1 for the null character '\0'.

Shine, what do you think about:

char name [strlen (filename) + 11];

On GCC it should work and seems better than using the heap with malloc and free.
Shiki
Posts: 10
Joined: Fri Sep 02, 2005 10:33 am

Post by Shiki »

I'll get back to this tomorrow, hope it doesn't move along too much that the whole topic changes.

I was having problems with making it load a game from the UMD, had to copy the boot file out and run it from the memorystick to start up the UMD. Which seems stupid, but the UMD doesn't like me when I try to directly run the boot file.
elevationsnow
Posts: 22
Joined: Sat Sep 10, 2005 6:45 am

Post by elevationsnow »

Shine wrote:I don't know which pspsdk installation you are using, I'm using the source from svn. You can checkout it like this:

svn co svn://svn.ps2dev.org/psp/trunk/zlib
svn co svn://svn.ps2dev.org/psp/trunk/libpng
having trouble making this work could some one please explain how to do that
jason867
Posts: 78
Joined: Sun Jul 24, 2005 1:58 am
Contact:

Post by jason867 »

Shine wrote:
Panajev2001a wrote:For others who might have trouble using Jason's code, I thought it might be useful to see as many working implementations of it as possible.
I think one working implementation, which works with all pixel formats and all vram start adresses, is better:

main.c
Makefile
I finally got around to implementing your improved screenshot code (the version you put links to subversion of), and of course, being the n00b I am, I have a few errors giving me trouble.

I've isolated the problem to your showimage function, when I comment it out, the screenshot functions works great, but when I leave your showimage function in there, it outputs this to the shell;

Code: Select all

Owner@Pavilion1200 /usr/local/pspdev/psp/sdk/My_Homebrew/test
$ make
psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall   -c -o main.o mai
n.c
psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall  -L. -L/usr/local/
pspdev/psp/sdk/lib   main.o -lpng -lz -lpspdebug -lpspdisplay -lpspge -lpspctrl
-lpspsdk -lc -lpspuser -lpspkernel -o test.elf
/usr/local/pspdev/lib/gcc/psp/4.0.1/../../../../psp/lib/libpng.a&#40;pngrtran.o&#41;&#58; In
 function `png_build_gamma_table'&#58;
pngrtran.c&#58;&#40;.text+0x1264&#41;&#58; undefined reference to `pow'
pngrtran.c&#58;&#40;.text+0x147c&#41;&#58; undefined reference to `pow'
pngrtran.c&#58;&#40;.text+0x1524&#41;&#58; undefined reference to `pow'
pngrtran.c&#58;&#40;.text+0x163c&#41;&#58; undefined reference to `pow'
pngrtran.c&#58;&#40;.text+0x1718&#41;&#58; undefined reference to `pow'
/usr/local/pspdev/lib/gcc/psp/4.0.1/../../../../psp/lib/libpng.a&#40;pngrtran.o&#41;&#58;png
rtran.c&#58;&#40;.text+0x1804&#41;&#58; more undefined references to `pow' follow
collect2&#58; ld returned 1 exit status
make&#58; *** &#91;test.elf&#93; Error 1

Owner@Pavilion1200 /usr/local/pspdev/psp/sdk/My_Homebrew/test
$
And here is my screenshot.h file;

Code: Select all

//////////////////////////////////////////////////////////////////////////////////////////
// Screenshot.h Version 1.0
// By Jason J. Owens
// September 10, 2005 6&#58;27 AM
//////////////////////////////////////////////////////////////////////////////////////////

#ifndef __SCREENSHOT__
#define __SCREENSHOT__
//////////////////////////////////////////////////////////////////////////////////////////
// #includes
#include <png.h>
//////////////////////////////////////////////////////////////////////////////////////////

// Function Prototypes
void Screenshot&#40;const char* filename&#41;;
void user_warning_fn&#40;png_structp png_ptr, png_const_charp warning_msg&#41;;
void ShowImage&#40;const char* filename&#41;;
//////////////////////////////////////////////////////////////////////////////////////////

// Function Definitions
// Saves the current contents of the screen to the filepath passed to 'filename'
void Screenshot&#40;const char* filename&#41;
&#123;
        u32* vram32;
        u16* vram16;
        int bufferwidth;
        int pixelformat;
        int unknown;
        int i, x, y;
        png_structp png_ptr;
        png_infop info_ptr;
        FILE* fp;
        u8* line;
        
        fp = fopen&#40;filename, "wb"&#41;;
        if &#40;!fp&#41; return;
        png_ptr = png_create_write_struct&#40;PNG_LIBPNG_VER_STRING, NULL, NULL, NULL&#41;;
        if &#40;!png_ptr&#41; return;
        info_ptr = png_create_info_struct&#40;png_ptr&#41;;
        if &#40;!info_ptr&#41; &#123;
                png_destroy_write_struct&#40;&png_ptr, &#40;png_infopp&#41;NULL&#41;;
                fclose&#40;fp&#41;;
                return;
        &#125;
        png_init_io&#40;png_ptr, fp&#41;;
        png_set_IHDR&#40;png_ptr, info_ptr, SCR_WIDTH, SCR_HEIGHT,
                8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE,
                PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT&#41;;
        png_write_info&#40;png_ptr, info_ptr&#41;;
        line = &#40;u8*&#41; malloc&#40;SCR_WIDTH * 3&#41;;
        sceDisplayWaitVblankStart&#40;&#41;;  // if framebuf was set with PSP_DISPLAY_SETBUF_NEXTFRAME, wait until it is changed
        sceDisplayGetFrameBuf&#40;&#40;void*&#41;&vram32, &bufferwidth, &pixelformat, &unknown&#41;;
        vram16 = &#40;u16*&#41; vram32;
        for &#40;y = 0; y < SCR_HEIGHT; y++&#41; &#123;
                for &#40;i = 0, x = 0; x < SCR_WIDTH; x++&#41; &#123;
                        u32 color = 0;
                        u8 r = 0, g = 0, b = 0;
                        switch &#40;pixelformat&#41; &#123;
                                case PSP_DISPLAY_PIXEL_FORMAT_565&#58;
                                        color = vram16&#91;x + y * bufferwidth&#93;;
                                        r = &#40;color & 0x1f&#41; << 3; 
                                        g = &#40;&#40;color >> 5&#41; & 0x3f&#41; << 2 ;
                                        b = &#40;&#40;color >> 11&#41; & 0x1f&#41; << 3 ;
                                        break;
                                case PSP_DISPLAY_PIXEL_FORMAT_5551&#58;
                                        color = vram16&#91;x + y * bufferwidth&#93;;
                                        r = &#40;color & 0x1f&#41; << 3; 
                                        g = &#40;&#40;color >> 5&#41; & 0x1f&#41; << 3 ;
                                        b = &#40;&#40;color >> 10&#41; & 0x1f&#41; << 3 ;
                                        break;
                                case PSP_DISPLAY_PIXEL_FORMAT_4444&#58;
                                        color = vram16&#91;x + y * bufferwidth&#93;;
                                        r = &#40;color & 0xf&#41; << 4; 
                                        g = &#40;&#40;color >> 4&#41; & 0xf&#41; << 4 ;
                                        b = &#40;&#40;color >> 8&#41; & 0xf&#41; << 4 ;
                                        break;
                                case PSP_DISPLAY_PIXEL_FORMAT_8888&#58;
                                        color = vram32&#91;x + y * bufferwidth&#93;;
                                        r = color & 0xff; 
                                        g = &#40;color >> 8&#41; & 0xff;
                                        b = &#40;color >> 16&#41; & 0xff;
                                        break;
                        &#125;
                        line&#91;i++&#93; = r;
                        line&#91;i++&#93; = g;
                        line&#91;i++&#93; = b;
                &#125;
                png_write_row&#40;png_ptr, line&#41;;
        &#125;
        free&#40;line&#41;;
        png_write_end&#40;png_ptr, info_ptr&#41;;
        png_destroy_write_struct&#40;&png_ptr, &#40;png_infopp&#41;NULL&#41;;
        fclose&#40;fp&#41;;
&#125;
//////////////////////////////////////////////////////////////////////////////////////////

// Function to pass warnings to, and it ignores them.
void user_warning_fn&#40;png_structp png_ptr, png_const_charp warning_msg&#41;
&#123;
        // ignore PNG warnings
&#125;
//////////////////////////////////////////////////////////////////////////////////////////

// Display screenshot saved at the filepath passed to 'filename'.
void ShowImage&#40;const char* filename&#41;
&#123;
        u32* vram32;
        u16* vram16;
        int bufferwidth;
        int pixelformat;
        int unknown;
        png_structp png_ptr;
        png_infop info_ptr;
        unsigned int sig_read = 0;
        png_uint_32 width, height;
        int bit_depth, color_type, interlace_type, x, y;
        u32* line;
        FILE *fp;

        if &#40;&#40;fp = fopen&#40;filename, "rb"&#41;&#41; == NULL&#41; return;
        png_ptr = png_create_read_struct&#40;PNG_LIBPNG_VER_STRING, NULL, NULL, NULL&#41;;
        if &#40;png_ptr == NULL&#41; &#123;
                fclose&#40;fp&#41;;
                return;
        &#125;
        png_set_error_fn&#40;png_ptr, &#40;png_voidp&#41; NULL, &#40;png_error_ptr&#41; NULL, user_warning_fn&#41;;
        info_ptr = png_create_info_struct&#40;png_ptr&#41;;
        if &#40;info_ptr == NULL&#41; &#123;
                fclose&#40;fp&#41;;
                png_destroy_read_struct&#40;&png_ptr, png_infopp_NULL, png_infopp_NULL&#41;;
                return;
        &#125;
        png_init_io&#40;png_ptr, fp&#41;;
        png_set_sig_bytes&#40;png_ptr, sig_read&#41;;
        png_read_info&#40;png_ptr, info_ptr&#41;;
        png_get_IHDR&#40;png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, &interlace_type, int_p_NULL, int_p_NULL&#41;;
        png_set_strip_16&#40;png_ptr&#41;;
        png_set_packing&#40;png_ptr&#41;;
        if &#40;color_type == PNG_COLOR_TYPE_PALETTE&#41; png_set_palette_to_rgb&#40;png_ptr&#41;;
        if &#40;color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8&#41; png_set_gray_1_2_4_to_8&#40;png_ptr&#41;;
        if &#40;png_get_valid&#40;png_ptr, info_ptr, PNG_INFO_tRNS&#41;&#41; png_set_tRNS_to_alpha&#40;png_ptr&#41;;
        png_set_filler&#40;png_ptr, 0xff, PNG_FILLER_AFTER&#41;;
        line = &#40;u32*&#41; malloc&#40;width * 4&#41;;
        if &#40;!line&#41; &#123;
                fclose&#40;fp&#41;;
                png_destroy_read_struct&#40;&png_ptr, png_infopp_NULL, png_infopp_NULL&#41;;
                return;
        &#125;
        sceDisplayWaitVblankStart&#40;&#41;;  // if framebuf was set with PSP_DISPLAY_SETBUF_NEXTFRAME, wait until it is changed
        sceDisplayGetFrameBuf&#40;&#40;void*&#41;&vram32, &bufferwidth, &pixelformat, &unknown&#41;;
        vram16 = &#40;u16*&#41; vram32;
        for &#40;y = 0; y < height; y++&#41; &#123;
                png_read_row&#40;png_ptr, &#40;u8*&#41; line, png_bytep_NULL&#41;;
                for &#40;x = 0; x < width; x++&#41; &#123;
                        u32 color32 = line&#91;x&#93;;
                        u16 color16;
                        int r = color32 & 0xff;
                        int g = &#40;color32 >> 8&#41; & 0xff;
                        int b = &#40;color32 >> 16&#41; & 0xff;
                        switch &#40;pixelformat&#41; &#123;
                                case PSP_DISPLAY_PIXEL_FORMAT_565&#58;
                                        color16 = &#40;r >> 3&#41; | &#40;&#40;g >> 2&#41; << 5&#41; | &#40;&#40;b >> 3&#41; << 11&#41;;
                                        vram16&#91;x + y * bufferwidth&#93; = color16;
                                        break;
                                case PSP_DISPLAY_PIXEL_FORMAT_5551&#58;
                                        color16 = &#40;r >> 3&#41; | &#40;&#40;g >> 3&#41; << 5&#41; | &#40;&#40;b >> 3&#41; << 10&#41;;
                                        vram16&#91;x + y * bufferwidth&#93; = color16;
                                        break;
                                case PSP_DISPLAY_PIXEL_FORMAT_4444&#58;
                                        color16 = &#40;r >> 4&#41; | &#40;&#40;g >> 4&#41; << 4&#41; | &#40;&#40;b >> 4&#41; << 8&#41;;
                                        vram16&#91;x + y * bufferwidth&#93; = color16;
                                        break;
                                case PSP_DISPLAY_PIXEL_FORMAT_8888&#58;
                                        color32 = r | &#40;g << 8&#41; | &#40;b << 16&#41;;
                                        vram32&#91;x + y * bufferwidth&#93; = color32;
                                        break;
                        &#125;
                &#125;
        &#125;
        free&#40;line&#41;;
        png_read_end&#40;png_ptr, info_ptr&#41;;
        png_destroy_read_struct&#40;&png_ptr, &info_ptr, png_infopp_NULL&#41;;
        fclose&#40;fp&#41;;
&#125;
//////////////////////////////////////////////////////////////////////////////////////////

#endif

//////////////////////////////////////////////////////////////////////////////////////////
Any ideas?
Ask not for whom the bell tolls, it tolls for thee, besides, I'm playing my PSP, tee hee!
------------------------------------------------------
Visit my website for my PSP Homebrew!
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Post by Shine »

Add "-lm" in your Makefile
jason867
Posts: 78
Joined: Sun Jul 24, 2005 1:58 am
Contact:

Post by jason867 »

I completely missed that! I just glanced at your makefile and thought it was the same as before. Yeah, that fixed it, thanks!

By the way, how do you make comments in makefiles, it's the character '@' right?

I had a couple more questions, but I can't think of them at the moment.

Thanks again for all the help.
Ask not for whom the bell tolls, it tolls for thee, besides, I'm playing my PSP, tee hee!
------------------------------------------------------
Visit my website for my PSP Homebrew!
loko
Posts: 6
Joined: Sat Jul 23, 2005 11:07 pm

Post by loko »

That's a piece of code dude !

I'm now working on it to enable taking screenshots from an umd game. I've never managed to get umd launching in is own parallel thread.

I'm making a tool that configure action buttons before launching an umd game.

I'm dreaming of taking official game screenshots, it would definetly make me buying more umd games

Someone help ?

thanks in advance.
Shiki
Posts: 10
Joined: Fri Sep 02, 2005 10:33 am

Post by Shiki »

back here again.

loko I've been able to do what you're trying to produce, but using the code provided does not seem to perform very well for producing screenshots while there is an animation happening.

Also my program sometimes doesn't like to load the UMD. Probably because it isn't activated, not sure how to handle that.
Shine wrote:In the libpng folder is a sample, how to save one image at once, which uses 522240 bytes instead of only one line with 1920 bytes. If this is ok for your application, you should try it, but I don't think that it helps much.
Where is this sample? I can't seem to find it.
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Post by Shine »

Shiki wrote:
Shine wrote:In the libpng folder is a sample, how to save one image at once, which uses 522240 bytes instead of only one line with 1920 bytes. If this is ok for your application, you should try it, but I don't think that it helps much.
Where is this sample? I can't seem to find it.
http://svn.ps2dev.org/listing.php?repna ... rev=0&sc=0
Shiki
Posts: 10
Joined: Fri Sep 02, 2005 10:33 am

Post by Shiki »

Shine wrote:
Shiki wrote:
Shine wrote:In the libpng folder is a sample, how to save one image at once, which uses 522240 bytes instead of only one line with 1920 bytes. If this is ok for your application, you should try it, but I don't think that it helps much.
Where is this sample? I can't seem to find it.
http://svn.ps2dev.org/listing.php?repna ... rev=0&sc=0
Well Shine, that's the example I used last time. :( No other examples?
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Post by Shine »

Shiki wrote:Well Shine, that's the example I used last time. :( No other examples?
Sorry, was too early this morning :-)

http://svn.ps2dev.org/filedetails.php?r ... rev=0&sc=0
Shiki
Posts: 10
Joined: Fri Sep 02, 2005 10:33 am

Post by Shiki »

Thanks, I'll look into that.
Shiki
Posts: 10
Joined: Fri Sep 02, 2005 10:33 am

Post by Shiki »

Code: Select all

//png_write_row&#40;png_ptr, line&#41;;
row_pointers&#91;y&#93; = &line;
So I changed the code to put the line pointer address into the row_pointers but the image now doesn't seem to save correctly.

Code: Select all

png_write_image&#40;png_ptr, row_pointers&#41;;
I need a debugger.
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Post by Shine »

Shiki wrote:

Code: Select all

//png_write_row&#40;png_ptr, line&#41;;
row_pointers&#91;y&#93; = &line;
So I changed the code to put the line pointer address into the row_pointers but the image now doesn't seem to save correctly.
It doesn't make much sense, if you put the same line pointer to every row_pointers array entries. If you want to save it at once, you have to reserve as many rows as the image height. You'll need to use the sample from libpng as a base and customize it to your needs, not my sample. But I don't think that it will be faster.
Shiki
Posts: 10
Joined: Fri Sep 02, 2005 10:33 am

Post by Shiki »

Yeah, it's because you said it might not be faster I don't want to completely write another version that ends up being the same result.

What would be the fastest way of taking a screen dump?
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Post by Shine »

I think the fastest way would be not to access the memory stick, but using the WiFi interface. And then perhaps using the ME for compressing it, but you have to profile it, if compressing takes more time than the WiFi transfer.
User avatar
Saotome
Posts: 182
Joined: Sat Apr 03, 2004 3:45 am

Post by Saotome »

One good possibility to optimize it is to take the swtich/case instrutions out of the "for-loop", and do for each case an own for-loop, so it does't have to check for every pixel in which format to store it.
That should give quite a speedup, although i think the main bottleneck is the MS access, like you already said shine.
infj
holger
Posts: 204
Joined: Thu Aug 18, 2005 10:57 am

Post by holger »

maybe you get some significant speedup if you read the entire PNG to memory and then start the decoder instead of letting the decoder call read/seek for every chunk.
elevationsnow
Posts: 22
Joined: Sat Sep 10, 2005 6:45 am

Post by elevationsnow »

undefined reference to "deflate..."
undefined reference to "inflate..."
undefined reference to "crc32"
a bunch of stuff that looks like that
what am i doing wrong?
make file :

Code: Select all

TARGET = crazypaint2

OBJS = main.o

INCDIR = 
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $&#40;CFLAGS&#41; -fno-exceptions -fno-rtti
ASFLAGS = $&#40;CFLAGS&#41;

LIBDIR =
LIBS = -lm -lz -lpng
LDFLAGS =

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = crazypaint2


PSPSDK=$&#40;shell psp-config --pspsdk-path&#41;
include $&#40;PSPSDK&#41;/lib/build.mak
using jasons screenshot code[/code]
jason867
Posts: 78
Joined: Sun Jul 24, 2005 1:58 am
Contact:

Post by jason867 »

Did you install libpng and zlib via svn?
Ask not for whom the bell tolls, it tolls for thee, besides, I'm playing my PSP, tee hee!
------------------------------------------------------
Visit my website for my PSP Homebrew!
elevationsnow
Posts: 22
Joined: Sat Sep 10, 2005 6:45 am

Post by elevationsnow »

i installed both zlib and libpng
in that order

i did make, make install for zlib
and make, make install for libpng

i had the zlib and libpng folders in the psptoolchain folder im using cygwin
jason867
Posts: 78
Joined: Sun Jul 24, 2005 1:58 am
Contact:

Post by jason867 »

did you include <png.h>
and <zlib.h> (im not sure if you actually need this one or not...)

i typed all of this in with my psp browser! lol
Ask not for whom the bell tolls, it tolls for thee, besides, I'm playing my PSP, tee hee!
------------------------------------------------------
Visit my website for my PSP Homebrew!
elevationsnow
Posts: 22
Joined: Sat Sep 10, 2005 6:45 am

Post by elevationsnow »

haha good job btw i think that may fix it i had "png.h" instead of <png.h>
not sure why...
lol ive only been doing this for 2 weeks or so
elevationsnow
Posts: 22
Joined: Sat Sep 10, 2005 6:45 am

Post by elevationsnow »

nope didnt work it seems the undefines are in png.c and etc
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Post by Shine »

You could try the screenshot sample in the libpng folder to see if something is wrong with your program or with your psptoolchain setup.
elevationsnow
Posts: 22
Joined: Sat Sep 10, 2005 6:45 am

Post by elevationsnow »

yeah the compiler is a bitch and wants different order of libs for different programs
jasons optical chaos
-lz -lpng
my program
-lm -lpng -lz
Post Reply