TI3332 - Converting a BMP to a JPEG and Vice Versa
Product: Delphi
Version: All
Platform: Windows/Win32
Q: How do I convert a BMP to a JPEG and vice versa?
A: This little project demonstrates how to do it using the JPEG components that
ship with Delphi 3 (in the INFO\EXTRAS\JPEG directory). Just start a brand
new project in Delphi 3. Drop two TButtons on the form. Then double click on
the first button. Then double click on the second button. (This hooks the
event handlers up). Finally, replace the code inbetween "{$R *.DFM}" and
"end." in Unit1 with this code:
uses
JPEG;
procedure TForm1.Button1Click(Sender: TObject);
var
MyJPEG : TJPEGImage;
MyBMP : TBitmap;
begin
{ Convert a BMP to a JPEG }
MyBMP := TBitmap.Create;
with MyBMP do
try
LoadFromFile('YourBmpHere.BMP');
MyJPEG := TJPEGImage.Create;
with MyJPEG do begin
Assign(MyBMP);
SaveToFile('YourJpegHere.JPEG');
Free;
end;
finally
Free;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
MyJPEG : TJPEGImage;
MyBMP : TBitmap;
begin
{ Convert a JPEG to a BMP }
MyJPEG := TJPEGImage.Create;
with MyJPEG do begin
LoadFromFile('YourJpegHere.JPEG');
MyBMP := TBitmap.Create;
with MyBMP do begin
Width := MyJPEG.Width;
Height := MyJPEG.Height;
Canvas.Draw(0,0,MyJPEG);
SaveToFile('YourBmpHere.BMP');
Free;
end;
Free;
end;
end;
--------------------------------------------------------------------------------
DISCLAIMER: You have the right to use this technical information subject to the terms of the No-Nonsense License Statement that you received with the Borland product to which this information pertains.
--------------------------------------------------------------------------------
inprise 홈페이쥐에 갔더니 이런 FAQ가 있더군요.. 누구 GIF에 관한거 본적 있으신분
안계시나요??? 흑흑흑!!! 점점 급해지는데...
|