Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1168
  • Last Modified:

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++.
Thanx.
Arnaud.
0
arno_webmaster
Asked:
arno_webmaster
1 Solution
 
YunoshevCommented:
TJPEGImage in Delphi, may be CJPEGImage in Builder???
0
 
AlexVirochovskyCommented:
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...
}

0
 
jonninCommented:
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...
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
arno_webmasterAuthor Commented:
I found the answer by myself. In www.borland.com there is a section where it is possible to download a Tjpeg component for Borland 3. With the fils is provided an example.
0
 
arno_webmasterAuthor Commented:
I found the answer at www.borland.com but it was not easy at first sight.
0
 
AlexVirochovskyCommented:
aron_..., do you try use my code?
0
 
gysbert1Commented:
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 !
0
 
arno_webmasterAuthor Commented:
As i said, i have found the answer on www.borland.com. So i did not try the code. I have not much time for the moment but will check it later.
0
 
AlexVirochovskyCommented:
arno, if you don't use my code (or code from borland , that ~ same ), you can reject my reply.
Alex
0
 
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.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now