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

寫影像處理之像素值不對?

答題得分者是:mieng
yangkissktop
一般會員


發表:13
回覆:29
積分:8
註冊:2003-10-25

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-12-03 02:32:38 IP:61.59.xxx.xxx 未訂閱
請各位高手: 1.先在小畫家建立屬性大小為2x2之圖片: 黑白 白黑 2.在BCB拖一OpenPictureDialog 3.及一個2x2之TImage 4.程式碼如下: Graphics::TBitmap  *bitmap; if( FileExists(OpenPictureDialog1->FileName) ) {    Image1->Picture->LoadFromFile( OpenPictureDialog1->FileName ); // Image1->Picture->Bitmap->PixelFormat = pf24bit;        bitmap = new Graphics::TBitmap(); // bitmap->PixelFormat = pf24bit;    bitmap->Width  = 2;    bitmap->Height = 2;    bitmap->Canvas->CopyRect(Rect(0,0, 1,1), Image1->Picture->Bitmap->Canvas, Rect(0,0, 1,1)); // bitmap->Canvas->StretchDraw(TRect(0,0, 1,1), Image1->Picture->Bitmap);       Byte  *pixel;    for(int y=0 ; yScanLine[y]; for(int x=0 ; x
------
yangkissktop
mieng
中階會員


發表:12
回覆:97
積分:81
註冊:2003-10-31

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-12-03 10:48:46 IP:61.60.xxx.xxx 未訂閱
Graphics::TBitmap *bitmap;
if(FileExists(OpenPictureDialog1->FileName))
{
  Image1->Picture->LoadFromFile(OpenPictureDialog1->FileName);
  // Image1->Picture->Bitmap->PixelFormat = pf24bit;      bitmap = new Graphics::TBitmap();
  // bitmap->PixelFormat = pf24bit;
  bitmap->Width = 2;
  bitmap->Height = 2;
  bitmap->Canvas->CopyRect(Rect(0,0, 2,2), Image1->Picture->Bitmap->Canvas, Rect(0,0, 2,2));
  // bitmap->Canvas->StretchDraw(TRect(0,0, 1,1), Image1->Picture->Bitmap);      Byte *pixel;
  for(int y=0 ; y < 2 ; y  ){
    pixel = (Byte *)bitmap->ScanLine[y];
    for(int x=0 ; x <2 ; x  ) {
      AnsiString R; R  = "r:"; R  = pixel[3*x 2];
      AnsiString G; G  = "g:"; G  = pixel[3*x 1];
      AnsiString B; B  = "b:"; B  = pixel[3*x 0];
      ShowMessage( R G B );
    }
  }
}    以下為BCB的說明和範例    The following code illustrates the differences between CopyRect and BrushCopy. 
The bitmap graphic TARTAN.BMP?is loaded into Bitmap and displayed on the Canvas of Form1. 
BrushCopy replaces the color black in the graphic with the brush of the canvas, while CopyRect leaves the colors intact.    Graphics::TBitmap *Bitmap;    TRect   MyRect, MyOther;    MyRect = Rect(10,10,100,100);    MyOther = Rect(10,111,100, 201);
Bitmap = new Graphics::TBitmap;
Bitmap->LoadFromFile("c:\\windows\\tartan.bmp");
Form1->Canvas->BrushCopy(MyRect, Bitmap, MyRect, clBlack);
Form1->Canvas->CopyRect(MyOther, Bitmap->Canvas, MyRect);
delete Bitmap;
 
我想在copy時圖像大小要設大一點不要剛剛好就可以了,~~ 學習中請大家多多指導呦~~ ☆星霧☆(Mineg Chien WU) 發表人 - mieng 於 2003/12/03 10:55:01
yangkissktop
一般會員


發表:13
回覆:29
積分:8
註冊:2003-10-25

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-12-03 22:33:22 IP:61.59.xxx.xxx 未訂閱
謝謝樓上熱心的仁兄 ! 小弟已先測試出bug了 不過您還是有找到其中的一個問題 謝謝您 原因之一:>>>>>>>
------
yangkissktop
系統時間:2024-05-13 1:28:53
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!