Advertisement

Reading JPEGs without a library?!?!?

Started by December 06, 2000 02:00 PM
14 comments, last by MrSandman666 23 years, 11 months ago
Every time someone asks how to load a jpeg file every one tells him to use aome library to do it. Well, I want to use jpegs in my program but I don''t wanna use a library. It has to be possible to do that and I''m sure that someone has accomplished it before (at least the writers of the library) and I''m also sure that there is a tutorial about that somewhere out there. can anyone help me? "Mr Sandman bring me a dream"
-----------------------------"Mr Sandman bring me a dream"
Uhm, could you tell me WHY you don''t want to use a library? I use Intel jpeg library and it runs fast and is robust.
Advertisement
quote:
Original post by Anonymous Poster

Uhm, could you tell me WHY you don''t want to use a library? I use Intel jpeg library and it runs fast and is robust.


What fun is programming if you use a library to do everything?

I personally love to write these kinds of things because it''s a great learning experience and it''s fun to see if your code is better/faster than other libraries.

Besides, there''s no better feeling than knowing you are using YOUR code, not someone elses.


- Houdini
- Houdini
quote:
Original post by MrSandman666

Every time someone asks how to load a jpeg file every one tells him to use aome library to do it.
Well, I want to use jpegs in my program but I don''t wanna use a library. It has to be possible to do that and I''m sure that someone has accomplished it before (at least the writers of the library) and I''m also sure that there is a tutorial about that somewhere out there.

can anyone help me?

"Mr Sandman bring me a dream"


You can get the source code of libjpeg from linux and look how it works
you can find the source here

http://www.ijg.org/
Well, I don''t want to use a library for several reasons. First of all, it just feels better if you write the program entirely by yourself. Second, The program I''m writing is for a C++ class and it''s about MY code. They don''t wanna see how well I can search the web for some 3rd party libs. They want to see how well I can code.

And the soure code didn''t help me too much. I checked out the source of libjpeg and OpenIL but both didn''t help me much. They where really complicated and either incomplete or almost unreadable.

I was looking more for something like a tutorial.

"Mr Sandman bring me a dream"
-----------------------------"Mr Sandman bring me a dream"
Advertisement
You''re pretty much out of luck. There isn''t such thing as ''jpg tutorial''... I found a few fileformat specs, and was able to do it almost to the end - only huffman decoder gave me trouble (specs say that longest allowed code is 16bits... now where did that cursed 18-bit code is in a file came from...). Also, doing that ''by the book'', using standard IDCT is SLOW - 30 secs a pic, easily, with p500... And faster IDCT methods a pretty complicated, I just gave up and rewrote part of IJG''s code to suit my needs.
It took me about 20-30 hours of work to get that jpg loader to work properly, and it still can read only nonprogressive jpg''s and it reads properly only files written paint shop pro (I haven''t bothered to look for the problem with some other files, reading psp''s jpgs is good enough for me...).

But if you really want to do it, go ahead. Look for jpg fileformat specs at wotsit.org or other file format sites. Most of the docs simply suck, though, so you''ll need all the docs you can get. One thing might be well explained in some doc, but the same doc may be really shallow in the other fields...

~~~ "'impossible' is a word in the dictonary of fools" --Napoleon
Oh well, I think I have to use bitmaps and/or libraries then.
I think my teacher wouldn''t midn if I use a library. I''m using OpenGL anyways.

Well, thanks for all your help guys!

"Mr Sandman bring me a dream"
-----------------------------"Mr Sandman bring me a dream"
Last time I looked at wotsit.org I found a JPEG tutorial which explained it pretty well. I can''t remember if it was actuall wotsit that it came from as I''m not at my computer at the moment, but it does exist.
You people want to do it the hard way?

Why invent the wheel again? If someone provides you a good solution, why try to spend lots of hours doing your own solution?

I quess you ppl don''t even use OpenGl, DirectX or even C++. You program all your programs with pure machine language and hex edit, because only then you can be sure what''s really happening.

I''m 99.9999% sure that sandman''s jpeg code will be slower and crashes more often than Intel Jpeg Library. Why? IJL was written by professionals and it has been tested by thousands of people.

Get real.

This topic is closed to new replies.

Advertisement