13,874
社区成员
发帖
与我相关
我的任务
分享
#include <ToolWin.hpp>
#include <jpeg.hpp>
#include <pngimage.hpp>
#include <gifimage.hpp>
//---------------------------------------------------------------------------
enum PictureType { Bitmap, PNG, JPEG, ICO, GIF };
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
public: // User declarations
Graphics::TBitmap * bmpPicture;
TJPEGImage * jpgPicture;
TPNGObject * pngPicture;
TGIFImage * gifPicture;
Graphics::TIcon * icoPicture;
PictureType pctType;
__fastcall TForm1(TComponent* Owner);
};
if( ExtensionName == ".bmp" )
{
frmChild -> pctType = PictureType::Bitmap;
//Get the picture from the file
frmChild -> bmpPicture -> LoadFromFile(OpenPictureDialog1 -> FileName);
//Resize the child form to the size of picture
frmChild -> ClientWidth = frmChild -> bmpPicture -> Width;
frmChild -> ClientHeight = frmChild -> bmpPicture -> Height;
}
switch( pctType )
{
case PictureType::Bitmap:
Canvas -> Draw( 0, 0, bmpPicture );
break;
case PictureType::JPEG:
Canvas -> Draw( 0, 0, jpgPicture );
break;
case PictureType::PNG:
Canvas -> Draw( 0, 0, pngPicture );
break;
case PictureType::GIF:
Canvas -> Draw( 0, 0, gifPicture );
break;
case PictureType::ICO:
Canvas -> Draw( 0, 0, icoPicture );
break;
}