问我呀,我刚做了一个图像处理的毕业设计
void __fastcall TForm1::Button2Click(TObject *Sender)
{
lpSrc = new Graphics::TBitmap;
lpDst = new Graphics::TBitmap;
if(OpenPictureDialog1->Execute())
{
FileName = OpenPictureDialog1->FileName;
lpSrc->PixelFormat = pf1bit;
lpDst->PixelFormat = pf1bit;
lpSrc->LoadFromFile(FileName);
}
//Form1->Canvas->Draw(0,0,lpSrc);
Byte *p;
Byte r;
for(int x = 0; x < lpSrc->Height; x++)
{
p = (Byte*)(lpSrc->ScanLine[x]);
for(int y = 0; y < lpSrc->Width; y++)
{
r = p[y];
}
}
/*int value;
for(int x = 0; x < lpSrc->Height; x++)
{
for(int y = 0; y < lpSrc->Width; y++)
{
value = lpSrc->Canvas->Pixels[y][x];
}
}*/
}
我用上述两种方法,用跟踪调试显示出来的值不一样的啊!请问是为什么??图像我已经转换成了二值图像了。帮我看看,谢谢!
老大咋又不来了呢??我在线等候的啊!!你有能读二值图像的程序的话,能发到我的邮箱里吗?lionli2005@hotmail.com 万分感谢!!!!
void __fastcall TForm1::Button2Click(TObject *Sender)
{
lpSrc = new Graphics::TBitmap;
lpDst = new Graphics::TBitmap;
if(OpenPictureDialog1->Execute())
{
FileName = OpenPictureDialog1->FileName;
// lpSrc->PixelFormat = pf1bit;
// lpDst->PixelFormat = pf1bit;
lpSrc->LoadFromFile(FileName);
Edit1->Text = lpSrc->PixelFormat;//看一下是多少
}
//Form1->Canvas->Draw(0,0,lpSrc);
Byte *p;
Byte r;
for(int x = 0; x < lpSrc->Height; x++)
{
p = (Byte*)(lpSrc->ScanLine[x]);
for(int y = 0; y < lpSrc->Width; y++)
{
r = p[y];
}
}
/*int value;
for(int x = 0; x < lpSrc->Height; x++)
{
for(int y = 0; y < lpSrc->Width; y++)
{
value = lpSrc->Canvas->Pixels[y][x];
}
}*/
}
lpSrc->PixelFormat = pf1bit;
我现在没环境,没法调试,估计是这里的错。
这样查看一下Edit1->Text = lpSrc->PixelFormat;
pf1bit的值应该是2吧?