parano
一般會員
![](./myimg/board/mystar_empty.gif)
![](images/icon_photo_none.gif) 發表:14 回覆:6 積分:4 註冊:2007-02-02
發送簡訊給我
|
<textarea class="cpp" rows="10" cols="60" name="code">
void __fastcall TForm1::Button4Click(TObject *Sender)
{
Graphics::TBitmap *TheBitmap;
Graphics::TBitmap *Bmp = new Graphics::TBitmap();
Byte *ptr,*mptr,*u1ptr,*u2ptr,*d1ptr,*d2ptr;
int up1,up2,down1,down2,left1,left2,right1,right2;
float Gou;
Bmp->PixelFormat=pf24bit;
Bmp->Assign(Image1->Picture->Bitmap);
for(int y=0;yHeight;y )
{
up1=y-1;
up2=y-2;
down1=y 1;
down2=y 2;
if(up2<0)
up2=Bmp->Height-2;
if(down2==Bmp->Height)
down2=0;
ptr =(Byte *)TheBitmap->ScanLine[y];
mptr =(Byte *)Bmp->ScanLine[y];
u1ptr =(Byte *)Bmp->ScanLine[up1];
u2ptr =(Byte *)Bmp->ScanLine[up2];
d1ptr =(Byte *)Bmp->ScanLine[down1];
d2ptr =(Byte *)Bmp->ScanLine[down2];
for(int x=0;xWidth;x )
{
left1=x-1;
left2=x-2;
right1=x 1;
right2=x 2;
if(left2<0)
left2=Bmp->Width-2;
if(right2==Bmp->Width)
right2=0;
Gou=(u1ptr[left2] 4*u1ptr[left1] 7*u1ptr[x] 4*u1ptr[right1] u1ptr[right2]
4*u2ptr[left2] 16*u2ptr[left1] 26*u2ptr[x] 16*u2ptr[right1] 4*u2ptr[right2]
7*mptr[left2] 26*mptr[left1] 41*mptr[x] 26*mptr[right1] 7*mptr[right2]
4*d1ptr[left2] 16*d1ptr[left1] 26*d1ptr[x] 16*d1ptr[right1] 4*d1ptr[right2]
d2ptr[left2] 4*d2ptr[left1] 7*d2ptr[x] 4*d2ptr[right1] d2ptr[right2])/273;
ptr[x]=(Byte)Gou;
}
}
Image2->Picture->Assign(Bmp);
delete Bmp;
} </textarea>
這是我所寫的濾波程式,但執行程式的時候會有bug出現,不知道是哪裡出了錯說,請各位大大幫我看看,謝謝!!
|
Solaris2005
一般會員
![](./myimg/board/mystar_empty.gif)
![](images/icon_photo_none.gif) 發表:7 回覆:13 積分:4 註冊:2003-05-19
發送簡訊給我
|
ptr =(Byte *)TheBitmap->ScanLine[y]; <----因為它沒有來源, 所以就掛囉~~
===================引 用 文 章===================
<textarea class="cpp" rows="10" cols="60" name="code">void __fastcall TForm1::Button4Click(TObject *Sender)
{
Graphics::TBitmap *TheBitmap;
Graphics::TBitmap *Bmp = new Graphics::TBitmap();
Byte *ptr,*mptr,*u1ptr,*u2ptr,*d1ptr,*d2ptr;
int up1,up2,down1,down2,left1,left2,right1,right2;
float Gou;
Bmp->PixelFormat=pf24bit;
Bmp->Assign(Image1->Picture->Bitmap);
for(int y=0;yHeight;y )
{
up1=y-1;
up2=y-2;
down1=y 1;
down2=y 2;
if(up2<0)
up2=Bmp->Height-2;
if(down2==Bmp->Height)
down2=0;
ptr =(Byte *)TheBitmap->ScanLine[y];
mptr =(Byte *)Bmp->ScanLine[y];
u1ptr =(Byte *)Bmp->ScanLine[up1];
u2ptr =(Byte *)Bmp->ScanLine[up2];
d1ptr =(Byte *)Bmp->ScanLine[down1];
d2ptr =(Byte *)Bmp->ScanLine[down2];
for(int x=0;xWidth;x )
{
left1=x-1;
left2=x-2;
right1=x 1;
right2=x 2;
if(left2<0)
left2=Bmp->Width-2;
if(right2==Bmp->Width)
right2=0;
Gou=(u1ptr[left2] 4*u1ptr[left1] 7*u1ptr[x] 4*u1ptr[right1] u1ptr[right2]
???? 4*u2ptr[left2] 16*u2ptr[left1] 26*u2ptr[x] 16*u2ptr[right1] 4*u2ptr[right2]
???? 7*mptr[left2] 26*mptr[left1] 41*mptr[x] 26*mptr[right1] 7*mptr[right2]
???? 4*d1ptr[left2] 16*d1ptr[left1] 26*d1ptr[x] 16*d1ptr[right1] 4*d1ptr[right2]
???? d2ptr[left2] 4*d2ptr[left1] 7*d2ptr[x] 4*d2ptr[right1] d2ptr[right2])/273;
ptr[x]=(Byte)Gou;
}
}
Image2->Picture->Assign(Bmp);
delete Bmp;
}
</textarea> 這是我所寫的濾波程式,但執行程式的時候會有bug出現,不知道是哪裡出了錯說,請各位大大幫我看看,謝謝!!
|
ALTIS
初階會員
![](./myimg/board/mystar.gif)
![](images/icon_photo_none.gif) 發表:4 回覆:26 積分:31 註冊:2005-04-28
發送簡訊給我
|
<textarea class="cpp" rows="10" cols="60" name="code">
void __fastcall TForm1::Button4Click(TObject *Sender)
{
Graphics::TBitmap *TheBitmap;
Graphics::TBitmap *Bmp = new Graphics::TBitmap();
Byte *ptr,*mptr,*u1ptr,*u2ptr,*d1ptr,*d2ptr;
int up1,up2,down1,down2,left1,left2,right1,right2;
float Gou;
Bmp->PixelFormat=pf24bit;
Bmp->Assign(Image1->Picture->Bitmap);
for(int y=0;yHeight;y )
{
up1=y-1;
up2=y-2;
down1=y 1;
down2=y 2;
if(up1<0)
up1=Bmp->Height-2;
if(up2<0)
up2=Bmp->Height-2;
if(down1>=Bmp->Height)
down1=0;
if(down2>=Bmp->Height)
down2=0;
ptr =(Byte *)TheBitmap->ScanLine[y];
mptr =(Byte *)Bmp->ScanLine[y];
u1ptr =(Byte *)Bmp->ScanLine[up1];
u2ptr =(Byte *)Bmp->ScanLine[up2];
d1ptr =(Byte *)Bmp->ScanLine[down1];
d2ptr =(Byte *)Bmp->ScanLine[down2];
for(int x=0;xWidth;x )
{
left1=x-1;
left2=x-2;
right1=x 1;
right2=x 2;
if(left2<0)
left2=Bmp->Width-2;
if(right2==Bmp->Width)
right2=0;
Gou=(u1ptr[left2] 4*u1ptr[left1] 7*u1ptr[x] 4*u1ptr[right1] u1ptr[right2]
4*u2ptr[left2] 16*u2ptr[left1] 26*u2ptr[x] 16*u2ptr[right1] 4*u2ptr[right2]
7*mptr[left2] 26*mptr[left1] 41*mptr[x] 26*mptr[right1] 7*mptr[right2]
4*d1ptr[left2] 16*d1ptr[left1] 26*d1ptr[x] 16*d1ptr[right1] 4*d1ptr[right2]
d2ptr[left2] 4*d2ptr[left1] 7*d2ptr[x] 4*d2ptr[right1] d2ptr[right2])/273;
ptr[x]=(Byte)Gou;
}
}
Image2->Picture->Assign(Bmp);
delete Bmp;
} </textarea>
------ 城市讓人迷惘 我在湖岸看見希望
妳的眼神是一道光芒 開啟我心中的收藏
編輯記錄
taishyang 重新編輯於 2007-04-20 11:01:45, 註解 無‧
|
海岸線
一般會員
![](./myimg/board/mystar_empty.gif)
![](images/icon_photo_none.gif) 發表:0 回覆:1 積分:0 註冊:2007-04-28
發送簡訊給我
|
如同Solaris2005所說的,所以你要在TheBitmap裡放一張影像
如TheBitmap->Assign(Image1->Picture->Bitmap);
------ succ
|
andyshooter
一般會員
![](./myimg/board/mystar_empty.gif)
![](images/icon_photo_none.gif) 發表:6 回覆:10 積分:3 註冊:2009-04-01
發送簡訊給我
|
請問這個程式能將依張BMP圖片的R G B 各過濾出一張圖片嗎???
我將這個程式用BCB開啟(MDI環境)
已經將程式中該修改的地方修過了
但是執行之後他會給我跳到 Return();去
請問這是怎麼回事???
我該如何修改呢?
|