我看到过一个控件,虽然我装不上,但是我还是看到过里面地代码:
procedure TFormMain.ButtonConvertClick(Sender: TObject);
var
GIF : TGIFImage;
Bitmap : TBitmap;
begin
ButtonConvert.Enabled := False;
try
GIF := TGIFImage.Create;
try
GIF.OnProgress := OnProgress;
// Load the GIF that will be converted
GIF.LoadFromFile('test.gif');
// Display the GIF
ImageGIF.Picture.Assign(GIF);
// Clear previous BMP view
ImageBMP.Picture.Assign(nil); ShowMessage('This demo loads a GIF from the file TEST.GIF,'+#13+
'converts it to a bitmap and saves it as TEST.BMP');
Bitmap := TBitmap.Create;
try
// Convert the GIF to a BMP
Bitmap.Assign(GIF);
// Save the BMP
Bitmap.SaveToFile('test.bmp');
// Display the BMP
ImageBMP.Picture.Assign(Bitmap);
finally
Bitmap.Free;
end;
finally
GIF.Free;
end;
finally
ButtonConvert.Enabled := True;
end;
end;
procedure TFormMain.ButtonConvertClick(Sender: TObject);
var
GIF : TGIFImage;
Bitmap : TBitmap;
begin
ButtonConvert.Enabled := False;
try
GIF := TGIFImage.Create;
try
GIF.OnProgress := OnProgress;
// Load the GIF that will be converted
GIF.LoadFromFile('test.gif');
// Display the GIF
ImageGIF.Picture.Assign(GIF);
// Clear previous BMP view
ImageBMP.Picture.Assign(nil); ShowMessage('This demo loads a GIF from the file TEST.GIF,'+#13+
'converts it to a bitmap and saves it as TEST.BMP');
Bitmap := TBitmap.Create;
try
// Convert the GIF to a BMP
Bitmap.Assign(GIF);
// Save the BMP
Bitmap.SaveToFile('test.bmp');
// Display the BMP
ImageBMP.Picture.Assign(Bitmap);
finally
Bitmap.Free;
end;
finally
GIF.Free;
end;
finally
ButtonConvert.Enabled := True;
end;
end;
var
Bitmap : TBitmap;
GIF : TGIFImage;
begin
ButtonConvert.Enabled := False;
try
Bitmap := TBitmap.Create;
try
// Load the bitmap that will be converted
Bitmap.LoadFromFile('test.bmp');
// Display the bitmap
ImageBMP.Picture.Assign(Bitmap);
// Clear previous GIF view
ImageGIF.Picture.Assign(nil); ShowMessage('This demo loads a bitmap from the file TEST.BMP,'+#13+
'converts it to a GIF and saves it as TEST.GIF'); GIF := TGIFImage.Create;
try
GIF.OnProgress := OnProgress;
// Convert the bitmap to a GIF
GIF.Assign(Bitmap);
// Save the GIF
GIF.SaveToFile('test.gif');
// Display the GIF
ImageGIF.Picture.Assign(GIF);
finally
GIF.Free;
end;
finally
Bitmap.Free;
end;
finally
ButtonConvert.Enabled := True;
end;
end;
MyJpeg: TJpegImage;
Image1: TImage;
begin
Image1:= TImage.Create(self);
MyJpeg:= TJpegImage.Create;
Image1.Picture.Bitmap.LoadFromFile('c:\windows\desktop\aa.BMP'); // Load the Bitmap from a file
MyJpeg.Assign(Image1.Picture.Bitmap); // Assign the BitMap to MyJpeg object
MyJpeg.CompressionQuality:=StrToInt('75');
MyJpeg.Compress;
MyJpeg.SaveToFile('c:\windows\desktop\test.JPG'); // Save the JPEG to Disk
end;