//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "TJPEGImageAssign.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
// BeginExample: TJPEGImageAssign
// Method: Jpeg.TJPEGImage.Create
// Method: Jpeg.TJPEGImage.Assign
// Method: Graphics.TGraphic.SaveToFile
// Property: ExtCtrls.TImage.Stretch

// BeginCode
/*
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 it's Picture property loaded
with a bitmap at design time.
*/

#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");
}
// EndCode
// EndExample: TJPEGImageAssign
//---------------------------------------------------------------------------
