世界上的人都可以将bmp转换为jpg,为什么我不可以??????????????????
procedure TForm1.Button1Click(Sender: TObject);
var
theJpeg : TJPEGImage ;
//thebmp : TBitmap;
theImage: TImage;
begin
theJpeg := TJpegImage.Create;
//thebmp := TBitmap.Create;
theImage:= TImage.Create(self);
try
with theJpeg do
begin
theImage.Picture.Bitmap.LoadFromFile('C:\Car.bmp');
Assign(theImage.Picture.Bitmap);
CompressionQuality:=StrToInt('75');
Compress;
SaveToFile('c:\Car.JPG');
end;
finally
theJpeg.Free;
theImage.Free;
end;
{
try
thebmp.LoadFromFile('C:\Car.bmp');
theJpeg.Assign(thebmp);
theJpeg.CompressionQuality:=StrToInt('75');
theJpeg.Compress;
theJpeg.SaveToFile('C:\Car.jpg');
finally
thebmp.Free;
theJpeg.Free;
end;}
end;
Delphi中的源程序都是类似我这样的,如下:
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('c:\oneeye.jpg')
end;
finally
jp.Free;
end;
end;
错误提示是:“Cannot assign a TBitmap to a TJPEGImage”.
我到底做错了什么?要这样惩罚我。