真彩图像缩略图问题。

eangel9 2003-08-30 09:50:17
请问在BCB中如何计算真彩图象的缩略图?
...全文
63 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
FallenAngel 2003-08-30
  • 打赏
  • 举报
回复
有一个讨巧的办法,不过,我不知道效果好不好,因为所有的图象都会缩放成一样大小,有些就会很难看!

TImageList *imgList ;
TListView * lstView ;

imgList->Width = xx ;imgList->Height = xx ;

然后获取文件名,显示在lstView里面,记住设好他们的ImageIndex

最后吗:
HANDLE hicon = ExtractIcon(Form1->Handle, filename.c_str(), i);
icon->Handle = hicon;
imgList->AddIcon(icon);

你试试效果怎么样吧,顺便说一句,我可没试过啊
tonylk 2003-08-30
  • 打赏
  • 举报
回复
delphi的代码,4领域插值法:

function StretchBmp(SrcBmp:TBitmap;DesBmp:TBitmap;StretchRate:Integer):Boolean;
//stretch an bitmap to a smaller bmp, stretchRate is from 0 to 100.
//from tangfeng
//2003.01.19
var
P1,P2:PByteArray;
x1,y1,x2,y2,r,g,b:Integer;
begin
Result:=false;
if StretchRate>=100 then
exit;
try
DesBmp.PixelFormat:=pf24Bit;
DesBmp.Width:=SrcBmp.Width*StretchRate div 100;
DesBmp.Height:=SrcBmp.Height*StretchRate div 100;
for y1:=0 to DesBmp.Height-1 do begin
y2:=y1*100 div StretchRate; //¼ÆËã³öSourceͼÏóÖжÔÓ¦µÄÏóËصãY·½ÏòλÖõÄÖµ
P1:=DesBmp.Scanline[y1];
for x1:=0 to DesBmp.Width-1 do begin
x2:=x1*100 div StretchRate; //¼ÆËã³öSourceͼÏóÖжÔÓ¦µÄÏóËصãX·½ÏòλÖõÄÖµ
P2:=SrcBmp.ScanLine[y2];
if (x1=0) or (x1=DesBmp.Width-1) or (y1=0) or (y1=DesBmp.Height-1) then begin
P1[x1*3]:=P2[x2*3];
P1[x1*3+1]:=P2[x2*3+1];
P1[x1*3+2]:=P2[x2*3+2];
continue;
end;
r:=P2[(x2-SrcBmp.Width)*3]+P2[(x2-1)*3]+P2[(x2+SrcBmp.Width)*3]+P2[(x2+1)*3]+P2[x2*3];
g:=P2[(x2-SrcBmp.Width)*3+1]+P2[(x2-1)*3+1]+P2[(x2+SrcBmp.Width)*3+1]+P2[(x2+1)*3+1]+P2[x2*3+1];
b:=P2[(x2-SrcBmp.Width)*3+2]+P2[(x2-1)*3+2]+P2[(x2+SrcBmp.Width)*3+2]+P2[(x2+1)*3+2]+P2[x2*3+2];
P1[x1*3]:=min(P2[x2*3],r div 5);
P1[x1*3+1]:=min(P2[x2*3+1],g div 5);
P1[x1*3+2]:=min(P2[x2*3+2],b div 5);
end;
end;
Result:=true;
except
end;
end;
RamjetZhang 2003-08-30
  • 打赏
  • 举报
回复
StrechDraw,这个CSDN很多例子。
klbt 2003-08-30
  • 打赏
  • 举报
回复
学习。

13,822

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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