我在做图像处理方面的工作,现在要把分开计算的r,g,b值保存成一个
Lontint型,因为我用的函数colortorgb将象素点值转换成longint值。
因此需要处理后保存成longint值。
ParanomicMatrix[x,y]:= (tempArr[2] shl 16) and (tempArr[1] shl 8)
and tempArr[0] ;
这里temparr是那个r,g,b数组,可是为什么我的赋值结果为0呢?导致图像变成了黑色的。请高手帮帮忙!
我没有做过图像处理,但从你的意图来看,似乎应该这样写:
ParanomicMatrix[x,y]:= (tempArr[2] shl 16) or (tempArr[1] shl 8)
or tempArr[0] ;
我不是很确定,提供两种参考意见:
1)rgb(0,0,0,)就是黑色,而且你的函数好像不对,应是shr不是shl.
2)ParanomicMatrix[x,y]:= (tempArr[2] shl 16) or (tempArr[1] shl 8)
or tempArr[0] ;
1,首先,你是按B-G-R(高到低)的顺序合成一个longint吗?
2,用and好像不对吧.
3,你的temparr数组是什么类型的?应该是DWORD吧?如果是byte按你的方法就不对了
那就试试这个
如果temparr是dword:
var
lint:Longint;
lint:=0;
lint:=(B AND $000000FF) SHL 24;
LINT:=LINT OR ((G AND $000000FF) SHL 16) ;
LINT:=LINT OR (R AND $000000FF);
其中rgb分别对应你的数组相应颜色元素