呵呵,这个问题高手也难答:谁用ListView做过类似ACDSee的浏览缩略图的控件?我们交流一下。(200分)

  • 主题发起人 shang_yan
  • 开始时间
to pengyt
当初我选用ListView来做,是觉得实现起来要简单一些。
如窗口大小改变后,缩略图的重新定位、缩略图大小的自由设置等功能做起来比较方便。
 
现在我也有这种感觉: listview在你说的这些方面是方便些, 不过我都已经
艰难的解决了这些问题了 :)
 
是的,我从你软件中看到你解决得很不错。特别是下面的功能很好,这是ACDSee等软件的
特色,我也将努力实现这一功能。

“对于有很多图的目录,你拉动滚动条到哪个位置,缩略图区域就先显示那个位置的缩略图.
还有就是图像打印功能,应该是很方便使用的.....”
 
to pengyt:
//如果你在拖动的过程中就一直在刷新,那CPU不是很忙 :) ?
这点我没试过不知道,应该是这样,要不然你早就解决掉了,还等着我在这里鸡蛋里挑骨头吗?[:D]
不过像ACDSee32 v2.4,它将Splitter的ResizeStyle属性为rsPattern,就没有这种问题了。
 
to shang_yan:
不好意思,刚给pengyt发完就被派出去出了趟小差[8D]
我的程序其实就一个函数,当时怎么也找不到ACDSee32 v2.4了,又不愿用更高的版本,所以就自己写了一个,
我打开过包含424个JPG文件的目录,用了一分钟!是不是很慢?不过我试了一下,没有你说的现象阿?
Edit1:要打开的目录的全路径
LVMain:就是用来显示缩略图的ListView
ResizeBitmap:用来产生缩略图的函数
里面有64是因为每个图片在按比例缩小后,放在一个64X64的区域内
ImageList1的Height和Width都是64

procedure TForm1.Button1Click(Sender: TObject);
var
sr: TSearchRec;
li: TListItem;
b: TBitmap;
j: TJPEGImage;
strFileNameExt: String;
imgIdx: Integer;
rate: Extended;
begin
LVMain.Clear;
ImageList1.Clear;
LVMain.Items.BeginUpdate;
b := TBitmap.Create;
j := TJPEGImage.Create;
sr.Size := SizeOf(sr);
if FindFirst(Edit1.Text + '/*.*', faAnyFile, sr) = 0 then
begin
repeat
if (sr.Attr and faDirectory) = faDirectory then
begin
if sr.Name <> '.' then
begin
li := LVMain.Items.Add;
li.Caption := sr.Name;
li.ImageIndex := -1;
end;
end
else// if (sr.Name <> '.') and (sr.Name <> '..') then
begin
strFileNameExt := LowerCase(ExtractFileExt(sr.Name));
if (strFileNameExt = '.jpeg') or (strFileNameExt = '.jpg') then
begin
li := LVMain.Items.Add;
li.Caption := sr.Name;
try
j.LoadFromFile(Edit1.Text + '/' + sr.Name);
b.Assign(j);
if (b.Width > 64) or (b.Height > 64) then
begin
rate := 64 / b.Height;
if rate > 64 / b.Width then rate := 64 / b.Width;
b := ResizeBitmap(b, rate);
end;
if b.Width <> 64 then b.Width := 64;
if b.Height <> 64 then b.Height := 64;
imgIdx := ImageList1.Add(b, nil);
if imgIdx <> -1 then li.ImageIndex := imgIdx else li.ImageIndex := -1;
except
li.ImageIndex := -1;
end;
end
else if strFileNameExt = '.bmp' then
begin
li := LVMain.Items.Add;
li.Caption := sr.Name;
try
b.LoadFromFile(Edit1.Text + '/' + sr.Name);
if (b.Width > 64) or (b.Height > 64) then
begin
rate := 64 / b.Height;
if rate > 64 / b.Width then rate := 64 / b.Width;
b := ResizeBitmap(b, rate);
end;
if b.Width <> 64 then b.Width := 64;
if b.Height <> 64 then b.Height := 64;
imgIdx := ImageList1.Add(b, nil);
if imgIdx <> -1 then li.ImageIndex := imgIdx else li.ImageIndex := -1;
except
end;
end;
end;
until
FindNext(sr) <> 0;
FindClose(sr);
end;

j.Free;
b.Free;
LVMain.Items.EndUpdate;
end;
 
to 独帅:
我们的方法基本差不多。今天我又用ListView作了一个简单的缩略图浏览控件,结果没有出
出我以前的问题,看来是我原来做的控件功能太多,一定有什么地方忘记将占用的资源释放了。
我自己再想办法解决吧。
谢谢各位。
 
有兴趣的可以再就此讨论,过几天统一结帐。
 
[8D][8D]
不错啊,我原来用VB做过一个,可以直接加入JPEG图像的,在DELPHI中就不行了,只好用格
式变换,但也没做。
听说在JPEG图像中是有一段略图内容的,有没有用它啊,如果每一次都要读完全图再简化,
是不是有点不太合算?
欢迎做成控件。
收藏。
 
我已做成了控件。
 
速度及效果怎样?我的为什么这样慢呢?
 
浏览JPG图片的速度比ACDSee(不建立缩略图数据库时)略慢一点,但比其它软件速度快
如果建立缩略图数据库,则速度差不多。其它格式的图我没有试。
 
多人接受答案了。
 
顶部