RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TJPEGImage.Create Constructor

Instantiates a jpeg image object.

Pascal
constructor Create; override;
C++
virtual __fastcall TJPEGImage();

Call Create to instantiate a jpeg image object at run time. Create allocates memory for a jpeg image object and then initializes its properties. After the jpeg is loaded from a file, an internal bitmap is created to hold the image.  

C++ Examples: 

 

/*
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");
}

 

Delphi Examples: 

{
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.
}
uses Jpeg;

procedure TForm1.Button1Click(Sender: TObject);
var
  jp: TJPEGImage;  //Requires the "jpeg" unit added to "uses" clause.
begin
  jp := TJPEGImage.Create;
  try
    with jp do
    begin
      Assign(Image1.Picture.Bitmap);
      SaveToFile('factory.jpg');
      Image2.Stretch := True;
      Image2.Picture.LoadFromFile('factory.jpg');
    end;
  finally
    jp.Free;
  end;
end;

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!