You could also use “TonyJpegLib”, wich consists of a single header and a
single cpp file. Should easily integrate into any project.
http://www.codeproject.com/bitmap/tonyjpeglib.asp
#include <tiny_targa.h>
#include
using namespace std;
inline int filesize(const char *s)
{
fstream f;
int size=0;
f.open(s, ios::binary | ios::in);
if(f.is_open())
{
f.seekg(0, ios::end ); // go to end of file
size = f.tellg();
f.close();
return size;
}
else
return 0;
}
#include “JpegDecoder.h”
void main()
{
char * fname=“skybox_back.jpg”;
int fsize=filesize(fname);
unsigned char * image_data = new unsigned char[fsize];
fstream f;
f.open(fname, ios::binary | ios::in);
f.read((char*)image_data, fsize);
f.close();
int w,h, header_size;
CTonyJpegDecoder jpg_decoder;
jpg_decoder.ReadJpgHeader(image_data, fsize, w, h, header_size);
unsigned char * image_out = new unsigned char[w*h*3];
jpg_decoder.DecompressImage(image_data, header_size, image_out);
Targa tga;
f.open("test_out.tga", ios::binary | ios::out);
stringstream s;
s.write((char*)image_out, w*h*3);
tga.save(f,s,w,h,24);
f.close();
}
This sample code uses a modified version of tonyjpeglib, that consists of
just a single header file (alle member function code moved into the class
definition) and my tiny_targa.h class for loading and saving tga - files.
http://www.coreloop.com/aknet/tutorials/tiny_targa_jpeg/JpegDecoder.h
http://www.coreloop.com/aknet/tutorials/tiny_targa_jpeg/tiny_targa.h
http://www.coreloop.com/aknet/tutorials/tiny_targa_jpeg/main.cpp> -----Original Message-----
From: sdl-bounces+post=andre-krause.net at libsdl.org
[mailto:sdl-bounces+post=andre-krause.net at libsdl.org] On
Behalf Of Michel Bardiaux
Sent: Dienstag, 2. August 2005 17:30
To: A list for developers using the SDL library. (includes
SDL-announce)
Subject: Re: [SDL] Project files for JPEG.DLL
Phil Steinmeyer wrote:
Does anyone know of (or have) any MSVC project files for
JPEG.DLL that
would allow me to recompile in MSVC 6 or 7? I got the source code
from the Independent JPEG Group, but they don’t have any
MSVC project
files, and when I tried to create my own, the resulting DLL
didn’t work for me.
Thanks,
Phil
Unless you want to recompile, e.g. because of your own
changes, take libjpeg at
http://sourceforge.net/projects/mingwrep/, that can be linked
with your apps in MSVC.
–
Michel Bardiaux
R&D Director
MediaXim S.A. Bd. du Souverain, 191 B-1160 Bruxelles Tel :
+32 2 790.29.41
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl