全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1697
推到 Plurk!
推到 Facebook!

設定XY軸來擷取圖片的問題.

答題得分者是:cmf
arnotsay
一般會員


發表:23
回覆:79
積分:20
註冊:2003-02-03

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-03-08 22:45:04 IP:218.162.xxx.xxx 未訂閱
我已經將原圖中要擷取的物體..的左上.左下.右上.右下..的XY 座標找到了.. 我要把擷取出來的物體另存一張圖顯示在 Image2 上.. 使得Image2 會比Image1小很多.. ex..Image1=320x240 Image2=30x20...    我寫了程式碼..不過run的結果Image2 還是跟Image1一樣大小...是我寫錯嗎?    Graphics::TBitmap *pBitmap=new Graphics::TBitmap; Graphics::TBitmap *pBitmap1=new Graphics::TBitmap;    for ( y =23 ; y <216); y ) { ptr1 = (Byte *)pBitmap->ScanLine[y]; ptr2 = (Byte *)pBitmap1->ScanLine[y]; for ( x = 157; x <150; x ) { b1=ptr1[x*3]; g1=ptr1[x*3 1]; r1=ptr1[x*3 2]; show1=(0.299*r1 0.587*g1 0.114*b1); ptr2[x*3]=(Byte)show1; ptr2[x*3 1]=(Byte)show1; ptr2[x*3 2]=(Byte)show1; } } Image2->Picture->Assign(pBitmap1);
cmf
尊榮會員


發表:84
回覆:918
積分:1032
註冊:2002-06-26

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-03-08 22:56:49 IP:61.70.xxx.xxx 未訂閱
Graphics::TBitmap *pBitmap=new Graphics::TBitmap; Graphics::TBitmap *pBitmap1=new Graphics::TBitmap;    pBitmap1->width =30; pBitmap1->height=20; int i,j; i=0; j=0;    for ( y =23 ; y <53); y++) { ptr1 = (Byte *)pBitmap->ScanLine[y]; ptr2 = (Byte *)pBitmap1->ScanLine[i]; for ( x = 157; x <177; x++) { b1=ptr1[x*3]; g1=ptr1[x*3+1]; r1=ptr1[x*3+2]; show1=(0.299*r1+0.587*g1+0.114*b1); ptr2[j*3]=(Byte)show1; ptr2[j*3+1]=(Byte)show1; ptr2[j*3+2]=(Byte)show1; j++; } i++; } Image2->Picture->Assign(pBitmap1); 僅供參考,歡迎繼續發言
------
︿︿
arnotsay
一般會員


發表:23
回覆:79
積分:20
註冊:2003-02-03

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-03-09 02:27:15 IP:218.162.xxx.xxx 未訂閱
引言: Graphics::TBitmap *pBitmap=new Graphics::TBitmap; Graphics::TBitmap *pBitmap1=new Graphics::TBitmap; pBitmap1->width =30; pBitmap1->height=20; int i,j; i=0; j=0; for ( y =23 ; y <53); y ) { ptr1 = (Byte *)pBitmap->ScanLine[y]; ptr2 = (Byte *)pBitmap1->ScanLine[i]; for ( x = 157; x <177; x ) { b1=ptr1[x*3]; g1=ptr1[x*3 1]; r1=ptr1[x*3 2]; show1=(0.299*r1 0.587*g1 0.114*b1); ptr2[j*3]=(Byte)show1; ptr2[j*3 1]=(Byte)show1; ptr2[j*3 2]=(Byte)show1; j ; } i ; } Image2->Picture->Assign(pBitmap1);
你好...請問是不是要加兩行?? pBitmap= Image1->Picture->Bitmap;這行我確定要加... pBitmap1= Image2->Picture->Bitmap;但是Image2原本沒有圖形..如果這樣寫 就會有錯誤...但是又不能不寫...不知有解決的方法嗎?
cmf
尊榮會員


發表:84
回覆:918
積分:1032
註冊:2002-06-26

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-03-09 02:46:05 IP:61.70.xxx.xxx 未訂閱
上面你的寫法是這樣 Graphics::TBitmap *pBitmap=new Graphics::TBitmap; Graphics::TBitmap *pBitmap1=new Graphics::TBitmap;    不清楚你要的是什麼,可以說清楚一點嗎 ? 3Q    僅供參考,歡迎繼續發言
------
︿︿
arnotsay
一般會員


發表:23
回覆:79
積分:20
註冊:2003-02-03

發送簡訊給我
#5 引用回覆 回覆 發表時間:2003-03-09 03:06:55 IP:218.162.xxx.xxx 未訂閱
引言: 上面你的寫法是這樣 Graphics::TBitmap *pBitmap=new Graphics::TBitmap; Graphics::TBitmap *pBitmap1=new Graphics::TBitmap; 不清楚你要的是什麼,可以說清楚一點嗎 ? 3Q
Graphics::TBitmap *pBitmap=new Graphics::TBitmap; pBitmap= Image1->Picture->Bitmap; 以上是放原圖...然後我要把裡面的一個物體割出來... 割出來的物體..我要以Image2來顯示...
cmf
尊榮會員


發表:84
回覆:918
積分:1032
註冊:2002-06-26

發送簡訊給我
#6 引用回覆 回覆 發表時間:2003-03-09 03:25:04 IP:61.70.xxx.xxx 未訂閱
    Graphics::TBitmap *pBitmap= Image1->Picture->Bitmap; Graphics::TBitmap *pBitmap1;    Image2->Picture->Bitmap->width =30; Image2->Picture->Bitmap->height=20; pBitmap1=Image2->Picture->Bitmap;        int i,j; i=0; j=0;    for ( y =23 ; y <53); y++) { ptr1 = (Byte *)pBitmap->ScanLine[y]; ptr2 = (Byte *)pBitmap1->ScanLine[i]; for ( x = 157; x <177; x++) { b1=ptr1[x*3]; g1=ptr1[x*3+1]; r1=ptr1[x*3+2]; show1=(0.299*r1+0.587*g1+0.114*b1); ptr2[j*3]=(Byte)show1; ptr2[j*3+1]=(Byte)show1; ptr2[j*3+2]=(Byte)show1; j++; } i++; } 僅供參考,歡迎繼續發言
------
︿︿
arnotsay
一般會員


發表:23
回覆:79
積分:20
註冊:2003-02-03

發送簡訊給我
#7 引用回覆 回覆 發表時間:2003-03-09 13:39:32 IP:218.162.xxx.xxx 未訂閱
引言: Graphics::TBitmap *pBitmap= Image1->Picture->Bitmap; Graphics::TBitmap *pBitmap1; Image2->Picture->Bitmap->width =30; Image2->Picture->Bitmap->height=20; pBitmap1=Image2->Picture->Bitmap;
cmf...我又學到一招...謝謝你 我的程式已經能正常work....謝謝你..我會更努力的...
cmf
尊榮會員


發表:84
回覆:918
積分:1032
註冊:2002-06-26

發送簡訊給我
#8 引用回覆 回覆 發表時間:2003-03-09 15:44:08 IP:61.70.xxx.xxx 未訂閱
努力就會有希望    加油 加油 加油    僅供參考,歡迎繼續發言
------
︿︿
taishyang
站務副站長


發表:377
回覆:5490
積分:4563
註冊:2002-10-08

發送簡訊給我
#9 引用回覆 回覆 發表時間:2003-03-09 19:28:38 IP:140.135.xxx.xxx 未訂閱
arnotsay:  
引言: 我已經將原圖中要擷取的物體..的左上.左下.右上.右下..的XY 座標找到了.. 我要把擷取出來的物體另存一張圖顯示在 Image2 上..
試試下面的Code Image2->Canvas->CopyRect(bmp->Canvas->ClipRect,Image1->Canvas,Rect(start.x,start.y,end.x,end.y)); 只需左上與右下兩點即可< >< > 順心 發表人 - taishyang 於 2003/03/09 20:39:53
arnotsay
一般會員


發表:23
回覆:79
積分:20
註冊:2003-02-03

發送簡訊給我
#10 引用回覆 回覆 發表時間:2003-03-10 22:02:35 IP:218.162.xxx.xxx 未訂閱
引言: 試試下面的Code Image2->Canvas->CopyRect(bmp->Canvas->ClipRect,Image1->Canvas,Rect(start.x,start.y,end.x,end.y)); 只需左上與右下兩點即可< >< >
你好..我有一個問題... 知道左上與右下..不就等於知道其他兩點嗎?
taishyang
站務副站長


發表:377
回覆:5490
積分:4563
註冊:2002-10-08

發送簡訊給我
#11 引用回覆 回覆 發表時間:2003-03-10 22:30:30 IP:140.135.xxx.xxx 未訂閱
arnotsay您好:      
引言:我已經將原圖中要擷取的物體..的左上.左下.右上.右下..的XY 座標找到了.. 我要把擷取出來的物體另存一張圖顯示在 Image2 上..
所以Image2->Canvas->CopyRect(bmp->Canvas->ClipRect,Image1->Canvas,Rect(start.x,start.y,end.x,end.y)); 只需左上與右下兩點即可
引言: 知道左上與右下..不就等於知道其他兩點嗎?
所以這是當然的啊< >< > 順心
系統時間:2024-04-18 17:52:51
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!