Friday, June 6, 2008

BCB Jpeg show

#include
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
TJPEGImage *jpg=new TJPEGImage;
void __fastcall TForm1::FormCreate(TObject *Sender)
{

jpg->LoadFromFile("test.jpg");

}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender){
Image1->Canvas->Draw(0,0,jpg);

Graphics::TBitmap *bmp = new Graphics::TBitmap;
TRect Dect, Sect;
Dect = Rect(0, 0, jpg->Width, jpg->Height);
Sect = Rect(0, 0, jpg->Width, jpg->Height);
//pb->Canvas->Brush->Style = bsClear;

bmp->Width = jpg->Width;
bmp->Height = jpg->Height;
bmp->Canvas->CopyRect(Dect, Image1->Canvas, Sect);

bmp->SaveToFile("c:\\test.bmp");
delete bmp;
delete jpg;

}