Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JPEG in an OpenPictureDialog 1

Status
Not open for further replies.

hennep

Programmer
Dec 10, 2000
429
When I click on a jpg, gif, tif file in an OpenPictureDialog the result is an error.
Can somebody tell how to open these files with the OpenPictureDialog.
So far only bmp seems to work.
 
Hi hennep

Sorry for taking so long to reply.

If you still happen to need a tip, when loading a jpeg into the TImage load it like so,

TJPEGImage *Jpeg = new TJPEGImage;
Graphics::TBitmap *Bmp=new Graphics::TBitmap();

//This line below only needed only if you had a Jpeg loaded using
//Image1->Picture->LoadFromFile("c:\\test.jpg");
Image1->Picture->Assign(NULL);

Jpeg->LoadFromFile("c:\\test.jpg");

Bmp->Assign(Jpeg);

TRect Rect( 0, 0, Bmp->Width, Bmp->Height);
Image1->Canvas->CopyRect(Rect,Bmp->Canvas,Rect);

This way the TImage thinks you actually have a TBitmap loaded.

There could be a better solution, if I find one I'll let you know.

:)
 
Thank btecho,
this works perfect.

Hennep


With the TGifImage from Anders Melander I can also load gif image the same way:

//add Gifimage.pas to the project
#include "Gifimage.hpp"
TGIFImage*gif = new TGIFImage
Graphics::TBitmap *Bmp=new Graphics::TBitmap();
Image1->Picture->Assign(NULL);
gif->LoadFromFile("c:\\test.gif");
Bmp->Assign(gif);
TRect Rect( 0, 0, Bmp->Width, Bmp->Height);
Image1->Canvas->CopyRect(Rect,Bmp->Canvas,Rect);
 
But nobody write about TIFF. How I can open it or where i can find component to do it?
 
I have never even seen a tiff file. tiff is so 90's.
HA HA :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top