下面是引用cmovies於2006-05-3 16:46發表的 :
ptr2 = (Byte*) Image2->Picture->Bitmap->ScanLine[row];
-> Image2 從哪裡來?
在 Button4Click 中 Image1 的 PixelFormat 沒有設定, 但程式內好像當成 pf8bit 來用?
呵~今天下午在學校時~
也剛好在重新整理時有發現...
可是卻也出了令一個問題= =
其他的都跟前者一樣~@@
低通時~卻無法完整掃完= =
不知道是不是他掃圖時...
連rgb值也考慮近去了???
所以無法正常???還是...
目前寫的程式複製程式
void __fastcall TForm1::Button4Click(TObject *Sender)
{
int low,up,down,left,right,col,row;
Byte *ptr2, *tptr, *uptr, *dptr;
if(Image2->Picture->Bitmap->Empty)
Image2->Picture->Bitmap=Image1->Picture->Bitmap;
for (row=0; row<Image2->Picture->Height; row++)
{
up =row-1;
if(up<0)
up=Image2->Picture->Height -1; //發現小於min(Height),則取max(Height)來使用
down =row+1;
if(down==Image2->Picture->Height)
down=0; //發現大於max(Height),則取min(Height)來使用
uptr = (Byte*) Image2->Picture->Bitmap->ScanLine[up];
tptr = (Byte*) Image2->Picture->Bitmap->ScanLine[row];
dptr = (Byte*) Image2->Picture->Bitmap->ScanLine[down];
for (col=0; col<Image2->Picture->Width; col++)
{
left =col-1;
if(left<0)
left=Image2->Picture->Width -1;//發現小於min(width),則取max(width)來使用
right =col+1;
if(right==Image2->Picture->Width)
right=0; //發現大於max(width),則取min(width)來使用
low = (int)(uptr[left] +uptr[col] +uptr[right]+
tptr[left] +tptr[col] +tptr[right]+
dptr[left] +dptr[col] +dptr[right] );
low=low/9;
tptr[col]= (Byte)(low);
}
}
//ShowMessage(col);
Repaint();
}