JPEG to BMP or JPEG to matrix

Hi experts,
i would like to develop a personal picture viewer. So i need to read JPEG format from disk file and use it as a table of RGB components with the correct size. I will use Borland C++ 5.
Does anyone have a source code for reading the JPEG format and placing it in a matrix? Or converting JPEG to BMP in a buffer because the BMP treatment is embedded in the picture object of C++.
Who is Participating?
AlexVirochovskyConnect With a Mentor Commented:
arno, if you don't use my code (or code from borland , that ~ same ), you can reject my reply.
TJPEGImage in Delphi, may be CJPEGImage in Builder???
Next code display jpeg  as Bitmap in TImage component.
After that you can save it(if need).

void __fastcall TMyForm::bnOpenClick( TObject * Sender )
// load file
if ( dlgOpen->Execute( ) )
// load JPEG
std::auto_ptr< TjpegImage > theJPEG( new TjpegImage ) ;
theJPEG->LoadFromFile( dlgOpen->FileName ) ;

// copy to bitmap
std::auto_ptr< Graphics::TBitmap > theMap( new
Graphics::TBitmap ) ;
theMap->Assign( theJPEG.get( ) ) ;

// show bitmap
MyImage->Picture->Assign( theMap.get( ) ) ;
} // if...

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

I was able to hack the tga writer in the standard jpg lib to create raw images (rgb array) if you still need that.  All you  have to do is strip off the lines that write the header, very easy...
arno_webmasterAuthor Commented:
I found the answer by myself. In there is a section where it is possible to download a Tjpeg component for Borland 3. With the fils is provided an example.
arno_webmasterAuthor Commented:
I found the answer at but it was not easy at first sight.
aron_..., do you try use my code?
Yunoshev told you about the component ...

After that AlexVirochovsky  gave you code showing how to use it.

I think you owe at least one of them the points !
arno_webmasterAuthor Commented:
As i said, i have found the answer on So i did not try the code. I have not much time for the moment but will check it later.
arno_webmasterAuthor Commented:
I don't use your code so i cannot give more than C, but i'll give you the points to close the question.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.