Display JPG tutorial?

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

Moderators: cheriff, TyRaNiD

Post Reply
thomas_fogh
Posts: 21
Joined: Fri Jul 20, 2007 10:22 pm
Location: Denmark

Display JPG tutorial?

Post by thomas_fogh »

Does anyone have a JPG tutorial?
Thanks!
BR, Thomas Fogh
picobsd
Posts: 18
Joined: Thu Apr 19, 2007 7:24 pm

Post by picobsd »

I have some sample code of using libjpeg to display jpeg file
willow :--)
Posts: 107
Joined: Sat Jan 13, 2007 11:50 am

Post by willow :--) »

I'm a beginner myself but so far here's what I understood :

Basically you load the jpeg in a memory structure, then you display it as a Texture on a 3D structure (like a sprite ?), then you send the 3d structure to the screen.

0) Search the forum, you'll find dozens of (almost working) sample codes for jpeg display

1) there is a good implementation of jpeg loading on luaplayer. Go to
http://svn.ps2dev.org/filedetails.php?r ... rev=0&sc=0
and look for Image* loadJpegImage(const char* filename) and
Image* loadJpegImageImpl
(you have to include "graphics.h" that defines the image structure).

2) Then you have to "blit" the image to the screen. for that, look at the "blit.c" sample in the sdk... You'll have to understand the basics of GU if you've never worked on 3D applications

3) You might have some problems between 16 bits (screen) and 24bits(jpeg)... I personnally solved that by changing the screen to 32 bits, but I guess it would be better to convert the image to 16bits...

(I am myself stuck with two problems currently:
- my image's height is bigger than screen's height
- I want to resize my image... I guess that's probably done by changing the cordinates of my vertices, but I don't know much about 3D....
Anyways scaling doesn't seem feasible with the default code provided by blit.c
)

If you don't understand the code that loads the jpeg, go to: http://www.jpegcameras.com/libjpeg/libjpeg-2.html. This is the jpeglib library explanation and to me it was easier to read this in parallel with code reading.
thomas_fogh
Posts: 21
Joined: Fri Jul 20, 2007 10:22 pm
Location: Denmark

Post by thomas_fogh »

Thanks, I will take a look at blit.c (I don't want to use the luaplayer).
I tried searching the forum, but the most relevant I found had a broken link for the sources:
http://forums.ps2dev.org/viewtopic.php?t=6574
BR, Thomas Fogh
willow :--)
Posts: 107
Joined: Sat Jan 13, 2007 11:50 am

Post by willow :--) »

thomas_fogh wrote: (I don't want to use the luaplayer).
Sorry, I wasn't clear enough. I meant that if you look at that code in LuaPlayer, you will understand how to do it yourself.
You actually both need the code to load the jpeg (that you can find in luaplayer's source code) AND the blitting functions from blit.c

as far as FileAssistant is concerned, google it, I'm pretty sure you'll find a link (but it's c++). or go to QJ.net, I got it there.
thomas_fogh
Posts: 21
Joined: Fri Jul 20, 2007 10:22 pm
Location: Denmark

Post by thomas_fogh »

Oh, okay :) I'll look into it!
Thanks!
Post Reply