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 

libjpg sample source?

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



Joined: 07 Aug 2006
Posts: 136

PostPosted: Sat Jul 26, 2008 12:01 am    Post subject: libjpg sample source? Reply with quote

I've compiled myPS2's libjpg (as the current libjpg in svn.ps2dev.org/ps2/trunk/libjpg doesn't compile), and copied libjpg.a and libjpg.h to the appropriate directories (thanks to ragnarok2040 for mentioning this idea in a thread), but I have no way of testing libjpg...

Might anyone have some source that requires libjpg, so I can do some testing?
_________________
I may be lazy, but I can...zzzZZZzzzZZZzzz...
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
ragnarok2040



Joined: 09 Aug 2006
Posts: 230

PostPosted: Sat Jul 26, 2008 2:21 pm    Post subject: Reply with quote

I don't have a full source, but I think I can post enough of an example on how to convert a jpg into a texture gsKit can use. It's based off what I saw in uLaunchelf. If you haven't patched libjpg with uLaunchelf's modified files, you should replace JPG_FIXED_WIDTH with JPG_NORMAL.
Code:

#include <stdio.h>
#include <libjpg.h>
#include <gsKit.h>

GSTEXTURE BG_TEX;

void loadJpg(void)
{
    jpgData *Jpg;
    u8 *ImgData;


    FILE *File = fopen(jpgPath, "r");
    if(File != NULL) {

        Jpg = jpgOpenFILE( File, JPG_WIDTH_FIX);
        ImgData = malloc ( Jpg->width * Jpg->height * (Jpg->bpp / 8) );
        jpgReadImage( Jpg, ImgData  );
        BG_TEX.PSM = GS_PSM_CT24;
        BG_TEX.Clut = NULL;
        BG_TEX.VramClut = 0;
        BG_TEX.Width = Jpg->width;
        BG_TEX.Height = Jpg->height;
        BG_TEX.Filter = GS_FILTER_LINEAR;
        BG_TEX.Mem = (void*)ImgData;
        BG_TEX.Vram = gsKit_vram_alloc(gsGlobal, gsKit_texture_size(BG_TEX.Width, BG_TEX.Height, BG_TEX.PSM), GSKIT_ALLOC_USERBUFFER);

        gsKit_texture_upload(gsGlobal, &BG_TEX);

    }
}


Since it's in the same vein :D, I was having trouble with the ps2sdk-ports version of libpng, so I found a way to compile it with the myPS2 version instead.

If you want to compile gsKit with ntba2's libpng:
get ps2sdk-ports/zlib
make && make install
get ntba2's libpng from the myPS2 project off SVN
get ps2sdk-ports/libpng
copy ntba2's libpng.a to ps2sdk/ports/lib
copy ps2sdk-ports/libpng/png.h to ps2sdk/ports/include
copy ps2sdk-ports/libpng/pngconf.h to ps2sdk/ports/include
modify gsKit's Makefile.global and change:
EE_LIBS += -lz -lpng
to
EE_LIBS += -lm -lz -lpng
Then define LIBPNG=$PS2SDK/ports and define ZLIB as the same.

Then you can use gsKit_texture_png(gsGlobal, &BG_TEX, pngPath); to load png images instead of using his libpng.h header.
Back to top
View user's profile Send private message
LBGSHI



Joined: 07 Aug 2006
Posts: 136

PostPosted: Sat Jul 26, 2008 2:23 pm    Post subject: Reply with quote

That's awesome; thanks a lot for your help. I'll start toying with all of this after I finish fixing another issue.

Thanks again.
_________________
I may be lazy, but I can...zzzZZZzzzZZZzzz...
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS2 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