var
opendlg:topendialog;
Jpeg:TjpegImage;
begin
opendlg:=topendialog.create(application);
try
opendlg.filename:=editimagepath.text;
opendlg.Filter:='image(*.jpg)|*.jpg|*.jpg';
opendlg.Options:=opendlg.Options+[ofpathmustexist];
if opendlg.Execute then
begin
editimagepath.text:=opendlg.filename;if not(editimagepath.text='') then
begin
if fileexists(editimagepath.text) then
begin
image1.picture.loadfromfile(editimagepath.text) ;
jpeg:=TjpegImage.Create() ;
//image1.picture.LoadFromFile(editimagepath.text);
jpeg.LoadFromFile(editimagepath.text);
//jpeg.Assign(image1.Picture.Graphic);
//application.messagebox(inttostr(jpeg.width),'错误',mb_ok)
jpeg.CompressionQuality:=30; //压缩率1~100
jpeg.Compress; //执行压缩
jpeg.SaveToFile('c:\a.jpg');
image2.Picture.loadfromfile('c:\a.jpg');
jpeg.Free;
opendlg.Free;
//保存新图像
editimagepath.text:=''end
else
application.messagebox('指定图片文件不存在','错误',mb_ok);
end elseapplication.messagebox('没有指定jpg图片文件','错误',mb_ok) ;
end else
begin
application.messagebox('没有指定jpg图片文件','错误',mb_ok) ;
end ; finally
end ; end;
opendlg:topendialog;
Jpeg:TjpegImage;
begin
opendlg:=topendialog.create(application);
try
opendlg.filename:=editimagepath.text;
opendlg.Filter:='image(*.jpg)|*.jpg|*.jpg';
opendlg.Options:=opendlg.Options+[ofpathmustexist];
if opendlg.Execute then
begin
editimagepath.text:=opendlg.filename;if not(editimagepath.text='') then
begin
if fileexists(editimagepath.text) then
begin
image1.picture.loadfromfile(editimagepath.text) ;
jpeg:=TjpegImage.Create() ;
//image1.picture.LoadFromFile(editimagepath.text);
jpeg.LoadFromFile(editimagepath.text);
//jpeg.Assign(image1.Picture.Graphic);
//application.messagebox(inttostr(jpeg.width),'错误',mb_ok)
jpeg.CompressionQuality:=30; //压缩率1~100
jpeg.Compress; //执行压缩
jpeg.SaveToFile('c:\a.jpg');
image2.Picture.loadfromfile('c:\a.jpg');
jpeg.Free;
opendlg.Free;
//保存新图像
editimagepath.text:=''end
else
application.messagebox('指定图片文件不存在','错误',mb_ok);
end elseapplication.messagebox('没有指定jpg图片文件','错误',mb_ok) ;
end else
begin
application.messagebox('没有指定jpg图片文件','错误',mb_ok) ;
end ; finally
end ; end;
解决方案 »
- socket通信,接收unix发送的数据包时,产生Socket 10053错误,windos发包却正常,求高手解决
- 在线等:delphi用createthread创建线程时传参数问题
- listview被form的背景色给盖住了
- ★★★哈哈哈,终于被提前释放了!!散分200★★★
- 文件处理问题。
- 关于菜单的问题
- (跪求)dbgrid中加入有下拉框的控件,如combobox等
- DrawText 如何设置 Tab 的宽度!!!
- 请问怎样报stringgrid的滚动条变成别的样子,高分奉送!(详细内容见里面)
- 請問我在一個局域網中用Win2000 Server連接網絡,怎麼能訪問本地(可以Ping通自己),不能訪問其他計算機?
- 打算用 Delphi 7 开发一个绿色小软件,需要用到数据库.
- 如何把多个表里的text字段内容和并到一个表的text字段中
//-----------
var
Jpeg : TJPEGImage;
Bmp : TBitmap;
begin
Bmp := TBitmap.Create;
try
Bmp.LoadFromFile('c:\1.bmp');
Jpeg := TJPEGImage.Create;
try
Jpeg.Assign(bmp);
jpeg.CompressionQuality := 30;
Jpeg.Compress;
//保存图片
Jpeg.SaveToFile('c:\a.jpg');
finally
Jpeg.Free;
end;
finally
Bmp.Free;
end;
end;