S
stigachen
Unregistered / Unconfirmed
GUEST, unregistred user!
小弟有一段c++ builder上图像黑白化的代码,现在想转到delphi平台上,有几处不太明白
希望大虾指点
代码如下:
void __fastcall TForm1::Button2Click(TObject *Sender)
{
//图象黑白化
TColor bgr=0;
TColor Cb,Cg,Cr;
for (int i = 0; i < 256; i++)
for (int j = 0; j < 256; j++)
{
bgr=Image1->Canvas->Pixels[j];
Cb=bgr & 0xff;
Cg=bgr & 0xff00; Cg=Cg >> 8;
Cr=bgr & 0xff0000; Cr=Cr >> 16;
WORD w=(Cb+Cg+Cr)/3;
Cb=(TColor)(w);
Cg=(TColor)(w << 8);
Cr=(TColor)(w << 16);
bgr=Cb | Cg | Cr;
Image1->Canvas->Pixels[j] = bgr;
nData[j]=(int)Cb;
}
其中:
Cb=bgr & 0xff;
Cg=bgr & 0xff00; Cg=Cg >> 8;
Cr=bgr & 0xff0000; Cr=Cr >> 16;
WORD w=(Cb+Cg+Cr)/3;
不知如何转成dellphi
希望大虾指点
代码如下:
void __fastcall TForm1::Button2Click(TObject *Sender)
{
//图象黑白化
TColor bgr=0;
TColor Cb,Cg,Cr;
for (int i = 0; i < 256; i++)
for (int j = 0; j < 256; j++)
{
bgr=Image1->Canvas->Pixels[j];
Cb=bgr & 0xff;
Cg=bgr & 0xff00; Cg=Cg >> 8;
Cr=bgr & 0xff0000; Cr=Cr >> 16;
WORD w=(Cb+Cg+Cr)/3;
Cb=(TColor)(w);
Cg=(TColor)(w << 8);
Cr=(TColor)(w << 16);
bgr=Cb | Cg | Cr;
Image1->Canvas->Pixels[j] = bgr;
nData[j]=(int)Cb;
}
其中:
Cb=bgr & 0xff;
Cg=bgr & 0xff00; Cg=Cg >> 8;
Cr=bgr & 0xff0000; Cr=Cr >> 16;
WORD w=(Cb+Cg+Cr)/3;
不知如何转成dellphi