如何用程序算出一副位图中绿色占RGB三色的百分率? 用 IntToHex(Image1.Canvas.Pixels[x,y],6)可以得到(x,y)点的RGB值(从000000到FFFFFF),建一个双重循环慢慢地读罢.祝你好运 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在Delphi中,若TColor类型变量小于零,则为系统颜色,可以用ColorToRGB转换为真实的颜色值。在TColor的非系统的值中,低24位(共32位,高8位另有它用)为红绿蓝颜色的成分值,红色占最低8位,绿色占次低字节,蓝色占更高一位字节。所以你可以这样统计:procedure GetColorRatio( Bitmap: TBitmap; var R_Ratio, G_Ratio, B_Ratio: Extended );var x, y: Integer; nR, nG, nB,nTotal: Integer; aColor: TColor;begin with Bitmap do for y:=0 to Height-1 do for x:=0 to Width-1 do begin aColor := Canvas.Pixels[x,y]; Inc( nR, aColor and $FF ); Inc( nG, (aColor shr 8) and $FF ); Inc( nB, (aColor shr 16) and $FF ); end; end; nTotal := nR+nG+nB; R_Ratio := nR*100.0/nTotal; G_Ratio := nG*100.0/nTotal; B_Ratio := nB*100.0/nTotal;end; 返回时:R_Ratio为红色的百分比,G_Ratio为绿色的百分比,B_Ratio为蓝色的百分比, 如何抓图,带鼠标 物料管理(MM)中该如何处理库存? 请教高手们问题,谁帮忙解决了100分全给她(他) ParamCount函数是什么 请教备份恢复的问题,100分,不够再给 请问有关打印报表的控件问题 怎么修改数据库啊~,怎么回有这中问题? 原来CSDN菜鸟多。这么简单的问题竟然没人知道?????????????????? 那位做过项目需求 这个问题太难了请教高手?! AVI问题 delphi50 有THTML控件吗?
在TColor的非系统的值中,低24位(共32位,高8位另有它用)为红绿蓝颜色的成分值,红色占最低8位,绿色占次低字节,蓝色占更高一位字节。所以你可以这样统计:procedure GetColorRatio( Bitmap: TBitmap; var R_Ratio, G_Ratio, B_Ratio: Extended );
var
x, y: Integer;
nR, nG, nB,nTotal: Integer;
aColor: TColor;
begin
with Bitmap do
for y:=0 to Height-1 do
for x:=0 to Width-1 do
begin
aColor := Canvas.Pixels[x,y];
Inc( nR, aColor and $FF );
Inc( nG, (aColor shr 8) and $FF );
Inc( nB, (aColor shr 16) and $FF );
end;
end;
nTotal := nR+nG+nB;
R_Ratio := nR*100.0/nTotal;
G_Ratio := nG*100.0/nTotal;
B_Ratio := nB*100.0/nTotal;
end;
返回时:R_Ratio为红色的百分比,G_Ratio为绿色的百分比,B_Ratio为蓝色的百分比,