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?
libjpg sample source?
libjpg sample source?
I may be lazy, but I can...zzzZZZzzzZZZzzz...
-
- Posts: 202
- Joined: Wed Aug 09, 2006 1:00 am
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.
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.
Code: Select all
#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);
}
}
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.