[Back To Directory]

Display JPEG:

1. Open Borland C++ Builder.
2. Place a Button on the form.
3. Place an Image on the form
4. Place an OpenDialog on the form
5. Double click Button1.
6. Type the following red code in the Button1Click function:

//NOTE: you will need to include this header file: #include < jpeg.hpp >
//This is what the Button1Click function should look like:

void __fastcall TForm1::Button1Click(TObject *Sender)
{
   TJPEGImage *jpeg = new TJPEGImage;

   OpenDialog1->Filter = "*.jpg, *.jpeg";
   if(OpenDialog1->Execute())
   {
      jpeg->LoadFromFile(OpenDialog1->FileName);
      Image1->Picture->Assign(jpeg);
   }
   delete jpeg;
}
//---------------------------------------------------------------------------


7. Run the program, click the button and browse to a jpeg. The jpeg will be loaded from a file to the image on the form.



[Back To Directory]