TJPEGImageAssign (C++)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example converts a bitmap image to a jpeg file by using the Assign method. This example requires a button and two images. One image must have its Picture property loaded with a bitmap at design time.


Code

#include <Jpeg.hpp>
#include <memory>       //For STL auto_ptr class

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  //Requires "jpeg.hpp" to be included in the source file.
  std::auto_ptr<TJPEGImage> jp(new TJPEGImage());
  jp->Assign(Image1->Picture->Bitmap);
  jp->SaveToFile("..\\factory.jpg");
  Image2->Stretch = True;
  Image2->Picture->LoadFromFile("..\\factory.jpg");
}

Uses