图象缩小且不太失真的Delphi算法--缩略图(100分)

  • 主题发起人 主题发起人 zhang214
  • 开始时间 开始时间
Z

zhang214

Unregistered / Unconfirmed
GUEST, unregistred user!
谁知道怎么生成缩略图,或者比较好的缩放代码或控件(主要是缩小的,不太失真的),谢谢!想说StretchDraw的朋友就帮忙置顶吧!
 
我也想要 顶!!!
 
gdi+
www.progdigy.com

procedure ToDrawThumbnail(Imagefilename: string);
var
gpCanvas: TGPGraphics;
gpBitmap: TGPImage;
gpThumbnail: TGPImage;
begin
gpCanvas:=TGPGraphics.Create(Form1.Canvas.Handle);
gpBitmap:= TGPBitmap.Create(Imagefilename);
gpCanvas.SetInterpolationMode(InterpolationModeHighQuality); //设置分辨率
gpThumbnail:= gpBitmap.GetThumbnailImage(64,64,nil,nil); //64*64大小的缩略图
gpCanvas.DrawImage(gpThumbnail, 100, 100, 64, 64);
gpThumbnail.free;
gpBitmap.free;
gpCanvas.free;
end;
 
我找到一个控件,graphi32 中的Timage32 ,能实现,但是有一问题,只有图片可见得时候
用bitblt 把缩图抓下来才行,否则当Timage32不可见的时候根本就不能操作...这点比较郁闷
 
我用到过,这个是我BMP类的一个缩小方法,缩小时不失真的
FGraphic就是TBitMap实例对象。
function TMyBmpEditer.Zoom(nWidth, nHeight: integer; IsScale,
IsInFrame: Boolean): Boolean;
begin
try
if IsScale then
GetScaleSize(FGraphic.Height, FGraphic.Width
, nHeight, nWidth, IsInFrame); //按比例计算新图大小

//缩小不失真的函数,设置图片扫描模式。
SetStretchBltMode(TBitmap(FGraphic).Canvas.Handle, HALFTONE);
TBitmap(FGraphic).Width := nWidth;
TBitmap(FGraphic).Height := nHeight;
TBitmap(FGraphic).Canvas.StretchDraw(TBitmap(FGraphic).Canvas.ClipRect
, FGraphic);
Result := true;
except
Result := false;
end;
end;
 
GetScaleSize ?是哪个单元的?
 
不好意思
,知道了..
 
GetScaleSize 是我自己写的,用来计算按比例缩小图的,你当它不存在就行了
 
to :晚起的小虫
不行呀,失真太厉害了.....
有谁有那种图象缩小不太失真的算法???类似graphi32中的就行了.或者gdi+中的也行...
好象不是很难吧....就是还没找到....
 
搞定,感谢gdi+ ,爽.....
GDI+的下载地址:http://www.progdigy.com/modules.php?name=Downloads&d_op=getit&lid=8
感谢所有朋友的参与.....今后大家用缩图的话就用gdi+吧.....
 
多人接受答案了。
 

Similar threads

I
回复
0
查看
666
import
I
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
后退
顶部