delphi实现JPG格式平滑图片压缩和自动转为RGB模式

ArideLee 2013-12-15 11:43:35
小弟最近在做一个产品管理系统时遇到3个问题:
1:将一个 1000*800像素的JPG图片通过程序按1/3压缩后 出现大量的噪点 显得很不协调,但是像画图等生成的缩小图却很平滑, 试验过很多方法 仍然解决不了,附效果:
其他软件效果:

自己生成效果:

锯齿和噪点比较多,如何平滑?

2:delphi的图像控件好像对 CMYK模式的JPG图片不怎么支持,一般需要转化为RGB模式,现在想通过程序自动完成 如何操作?

3:皮肤控件的问题: 有点类似于用友信息管理系统的批发效果,正常情况下 文本框就是一条横线,获得焦点后变成可编辑,组合框变成 一个小按钮上面有几个小点的那种,这种是什么皮肤控件?

这几个问题实在比较困扰,望各位大神指点迷津,谢了~~~
...全文
1539 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
fullhappy 2014-03-01
  • 打赏
  • 举报
回复
Graphics32确实能解决LZ的问题,可以网上搜索下的
lhy 2013-12-16
  • 打赏
  • 举报
回复
要不然自己计算每个点的值.
lhy 2013-12-16
  • 打赏
  • 举报
回复
你是用什么样的算法?
haitao 2013-12-16
  • 打赏
  • 举报
回复
引用 4 楼 u013161971 的回复:
[quote=引用 3 楼 sz_haitao 的回复:] gdi plus
C#下的GDI+试过 delphi下的能否给点建议?[/quote] 找到gdi+ for d的就行了,本坛maozefa写的 另外,如果只是转为外部文件,也可以利用开源的第三方图形库/工具 如cximage,我的批量转换工具就是d做界面,实际转换调用cximage的命令行程序: http://211.162.123.246:443/httpdisk/haitaosoft/?app=photolib
ArideLee 2013-12-16
  • 打赏
  • 举报
回复
引用 3 楼 sz_haitao 的回复:
gdi plus
C#下的GDI+试过 delphi下的能否给点建议?
haitao 2013-12-16
  • 打赏
  • 举报
回复
gdi plus
  • 打赏
  • 举报
回复
你还是用了StretchDraw,这个内部调用了Windows API StretchBlt或者TransparentStretchBlt,GDI实现的缩放是pixel resample算法,速度快,但是效果差,容易产生锯齿和变形,比较好的图像缩放算法是bicubic resample,对于真实感图像(典型如照片)效果尤其好。我不太清楚GDI+的图像缩放用了什么算法,但是效果要比GDI的好。
haitao 2013-12-16
  • 打赏
  • 举报
回复
引用 7 楼 u013161971 的回复:
[quote=引用 6 楼 lhylhy 的回复:] 你是用什么样的算法?
函数如下:{'use graphics, jpeg 輸入參數為 FileName : 檔案的名稱連路徑 Width : 輸出濶度 Height : 輸出高度 Quality : 輸出JPEG質量 (0最差 - 100最好)  回傳參數為 TJpegImage 格式 (兼容 TGraphic) } function StretchImageSmall(FileName : TFileName; WHRate, Quality : Integer) : TJpegImage; var Height, Width :Integer; bmp, tempbmp : TBitmap; RT : TRect; begin try if Uppercase(ExtractFileExt(FileName)) = '.JPG' then begin result := TjpegImage.Create; result.LoadFromFile(FileName); Height := Round(result.Height / WHRate*1.0); Width := Round(result.Width / WHRate*1.0); bmp := TBitmap.Create; bmp.Width := Width; bmp.Height := Height; RT.Left := 0; RT.Top := 0; RT.Right := Width - 1; RT.Bottom := Height - 1; bmp.PixelFormat := pf24bit; bmp.Canvas.StretchDraw(RT,result); result.Assign(bmp); result.CompressionQuality := Quality; result.Compress; end else exit; finally bmp.Free; end; end; //触发执行 Image1.Picture.Graphic := StretchImageSmall(ObjImgFilePath,3,100); Image1.Picture.SaveToFile(IMGFilePath + '\123.jpg'); //生成缩略图 [/quote] jpeg.pas里的缩略算法好像也不是非常强吧 感觉cximage的确不错
ArideLee 2013-12-16
  • 打赏
  • 举报
回复
引用 6 楼 lhylhy 的回复:
你是用什么样的算法?
函数如下:{'use graphics, jpeg 輸入參數為 FileName : 檔案的名稱連路徑 Width : 輸出濶度 Height : 輸出高度 Quality : 輸出JPEG質量 (0最差 - 100最好)  回傳參數為 TJpegImage 格式 (兼容 TGraphic) } function StretchImageSmall(FileName : TFileName; WHRate, Quality : Integer) : TJpegImage; var Height, Width :Integer; bmp, tempbmp : TBitmap; RT : TRect; begin try if Uppercase(ExtractFileExt(FileName)) = '.JPG' then begin result := TjpegImage.Create; result.LoadFromFile(FileName); Height := Round(result.Height / WHRate*1.0); Width := Round(result.Width / WHRate*1.0); bmp := TBitmap.Create; bmp.Width := Width; bmp.Height := Height; RT.Left := 0; RT.Top := 0; RT.Right := Width - 1; RT.Bottom := Height - 1; bmp.PixelFormat := pf24bit; bmp.Canvas.StretchDraw(RT,result); result.Assign(bmp); result.CompressionQuality := Quality; result.Compress; end else exit; finally bmp.Free; end; end; //触发执行 Image1.Picture.Graphic := StretchImageSmall(ObjImgFilePath,3,100); Image1.Picture.SaveToFile(IMGFilePath + '\123.jpg'); //生成缩略图
ArideLee 2013-12-15
  • 打赏
  • 举报
回复
引用 1 楼 sololie 的回复:
搜这个组件 Graphics32, 安装上去后,看Graphics32\demo 这个目录,你的啥问题都解决了
好的 我试试 多谢啦!
sololie 2013-12-15
  • 打赏
  • 举报
回复
搜这个组件 Graphics32, 安装上去后,看Graphics32\demo 这个目录,你的啥问题都解决了

1,183

社区成员

发帖
与我相关
我的任务
社区描述
Delphi GAME,图形处理/多媒体
社区管理员
  • GAME,图形处理/多媒体社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧