不知道为什么用listview显示缩略图总有问题,请大家帮忙看下下载地址里的工程源码,告诉我到底哪里出问题了,谢谢了
下载地址:
http://cnc.fs1.bay.cech.com.cn/download/23232781/adbrave/633767034992187500/55764ab7cca3ead81c8a55485739ba67/%E5%9B%BE%E7%89%87%E7%BC%A9%E7%95%A5%E5%9B%BE%E6%B5%8F%E8%A7%88.rar
下载地址:
http://cnc.fs1.bay.cech.com.cn/download/23232781/adbrave/633767034992187500/55764ab7cca3ead81c8a55485739ba67/%E5%9B%BE%E7%89%87%E7%BC%A9%E7%95%A5%E5%9B%BE%E6%B5%8F%E8%A7%88.rar
解决方案 »
- delphi FillRect中的参数错误 请大家帮忙看看
- 关于随机数的问题
- 高分求解--关于EXCEL数据导入到数据库的问题?
- 一个关于读取Memo字段内容的问题,为什么VFP能做到而Delphi做不到?
- 请问Delphi中有没有类似于VC中的sprintf,sscanf的函数?
- 一个有关DBTreeView控件的问题!
- 查询记录定位问题
- 怎么扑获异常?
- procedure InsertText(AHandle: THandle); far;~ 关键字 FAR 什么意思?
- 谁有将查询表query内的数据直接输出到excel文件的控件?
- ADOTABLE和ADOEDIT怎么做插入语句
- delphi里怎么使选择目录框能定义初始目录和选择"包括子目录"?
另外,你的jpeg文件找不到,没有包括到压缩包中。
procedure TForm1.Button2Click(Sender: TObject);
var
TheBitmap:TBitmap ;
TheJpeg:TJPEGImage;
aa:tlistitem;
i:integer;
begin
ImageList1.Clear;
for i:=1 to 4 do
begin
TheJpeg := TJPEGImage.Create;
TheJpeg.LoadFromFile('.\Images\'+inttostr(i)+'.jpg');
TheBitmap := TBitmap.Create ;
TheBitmap.Assign(TheJpeg);
ImageList1.Width:=80;
ImageList1.Height:=80;
ImageList1.Add(TheBitmap, nil) ;
aa:=listview1.Items.Add;
aa.Caption:=inttostr(i)+'.jpg';
aa.ImageIndex :=ImageList1.Count -1;
FreeAndNil(TheBitmap) ;
FreeAndNil(TheJpeg);
end;end;
procedure ScaleToBitmap(ASrc, ADest: TBitmap);
var
w, h, row, col: Integer;
sw, sh, scale: Single;
src, dest: PRGBTriple;
begin
w := ASrc.Width;
h := ASrc.Height;
sw := w / 80;
sh := h / 80;
scale := Max(sw, sh);
ADest.Width := Trunc(ASrc.Width / scale);
ADest.Height := Trunc(ASrc.Height / scale);
for row := 0 to ADest.Height - 1 do
begin
src := ASrc.ScanLine[Trunc(row * scale)];
dest := ADest.ScanLine[row];
for col := 0 to ADest.Width - 1 do
begin
dest^ := PRGBTriple(Integer(src) + SizeOf(TRGBTriple) * Trunc(col * scale))^;
Inc(dest);
end;
end;
end;procedure TForm1.Button2Click(Sender: TObject);
var
TheBitmap, DestBitmap:TBitmap ;
TheJpeg:TJPEGImage;
aa:tlistitem;
i:integer;
begin
ImageList1.Clear;
for i:=1 to 4 do
begin
TheJpeg := TJPEGImage.Create;
TheJpeg.LoadFromFile('.\Images\'+inttostr(i)+'.jpg');
TheBitmap := TBitmap.Create ;
TheBitmap.Assign(TheJpeg);
TheBitmap.PixelFormat := pf24Bit;
DestBitmap := TBitmap.Create;
DestBitmap.PixelFormat := pf24Bit;
ScaleToBitmap(TheBitmap, DestBitmap);
DestBitmap.Width := 80;
DestBitmap.Height := 80;
ImageList1.Width:=80;
ImageList1.Height:=80;
ImageList1.Add(DestBitmap, nil) ;
aa:=listview1.Items.Add;
aa.Caption:=inttostr(i)+'.jpg';
aa.ImageIndex :=ImageList1.Count -1;
FreeAndNil(DestBitmap);
FreeAndNil(TheBitmap) ;
FreeAndNil(TheJpeg);
end;end;
procedure ScaleToBitmap(ASrc, ADest: TBitmap);
var
w, h, newW, newH, row, col, offsetW, offsetH: Integer;
sw, sh, scale: Single;
src, dest: PRGBTriple;
begin
w := ASrc.Width;
h := ASrc.Height;
sw := w / 80;
sh := h / 80;
scale := Max(sw, sh);
newW := Trunc(ASrc.Width / scale);
newH := Trunc(ASrc.Height / scale);
offsetW := (ADest.Width - newW) div 2;
offsetH := (ADest.Height - newH) div 2;
for row := 0 to newH - 1 do
begin
src := ASrc.ScanLine[Trunc(row * scale)];
dest := PRGBTriple(Integer(ADest.ScanLine[offsetH + row]) + offsetW * SizeOf(TRGBTriple));
for col := 0 to newW - 1 do
begin
dest^ := PRGBTriple(Integer(src) + SizeOf(TRGBTriple) * Trunc(col * scale))^;
Inc(dest);
end;
end;
end;procedure TForm1.Button2Click(Sender: TObject);
var
TheBitmap, DestBitmap:TBitmap ;
TheJpeg:TJPEGImage;
aa:tlistitem;
i:integer;
begin
ImageList1.Clear;
for i:=1 to 5 do
begin
TheJpeg := TJPEGImage.Create;
TheJpeg.LoadFromFile('.\Images\'+inttostr(i)+'.jpg');
TheBitmap := TBitmap.Create ;
TheBitmap.Assign(TheJpeg);
TheBitmap.PixelFormat := pf24Bit;
DestBitmap := TBitmap.Create;
DestBitmap.Width := 80;
DestBitmap.Height := 80;
DestBitmap.PixelFormat := pf24Bit;
ScaleToBitmap(TheBitmap, DestBitmap);
ImageList1.Width:=80;
ImageList1.Height:=80;
ImageList1.Add(DestBitmap, nil) ;
aa:=listview1.Items.Add;
aa.Caption:=inttostr(i)+'.jpg';
aa.ImageIndex :=ImageList1.Count -1;
FreeAndNil(DestBitmap);
FreeAndNil(TheBitmap) ;
FreeAndNil(TheJpeg);
end;end;