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”.
我到底做错了什么?要这样惩罚我。
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”.
我到底做错了什么?要这样惩罚我。
解决方案 »
- 判断鼠标是否单击的函数是什么
- 请问如何得到窗体内的当前焦点在哪个控件上?谢谢
- 如何在98下对磁盘进行实模式读写?????
- DELPHI6中如何获取代理网关的IP地址!以及如何从DHCP服务器获取IP、ROUTE和DNS配置!
- 晕了~~~! 请众家兄弟帮小弟我看看这段代码,我真是搞不懂!!!
- 時間問題
- 过滤问题?????
- 关于SaveDialog,应该很简单的,可是我搞不定
- ///////////谁有打印及预览TF1Book的源代码\\\\\\\\\\\
- 我问的如何在DBGrid表格控件中为表格添加色带的问题,即第一行为灰色,第二行为白色,第三行为灰色,第四行为白色,依次类推,只能在Delphi自带的数据库中实现,
- 50分请教:初学者问一个关于在字符串中查找字符串的问题
- 如何展开treeview的所有接点?
Jpg:TJpegImage;Bmp:Tbitmap;
if Opendialog1.Filename<>'' then
begin
Bmp:=TBitmap.Create;
Bmp.LoadFromFile(Opendialog1.FileName);
Image1.Picture.LoadFromFile(Opendialog1.FileName);
end;if Savedialog1.filename<>'' then
begin
Jpg:=TJpegImage.Create;
Jpg.Assign(Bmp);
Jpg.CompressionQuality:=StrToInt(Edit1.Text);
Jpg.Compress;
Jpg.SaveToFile(Savedialog1.FileName);
Jpg.Free;
end;