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

圖形pixel値相減比對出現問題。

答題得分者是:richtop
tracydai1025
一般會員


發表:13
回覆:4
積分:3
註冊:2005-05-08

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-08-23 16:48:23 IP:218.165.xxx.xxx 未訂閱
程式碼是參照IORIS網友的。 內容是1 2 3 圖案與 A圖案 比較 但是比較出來的結果似乎出現錯誤 不管比對出來的結果都會直接把Image4的圖案直接顯現在Image5 不知道是哪裏出現問題?? 不好意思,打擾各位寶貴的時間看這篇文章,請指教。 謝謝 程式已上傳到檔案區 http://delphi.ktop.com.tw/topic.php?TOPIC_ID=77264
richtop
資深會員


發表:122
回覆:646
積分:468
註冊:2003-06-10

發送簡訊給我
#2 引用回覆 回覆 發表時間:2005-08-23 23:07:17 IP:211.76.xxx.xxx 未訂閱
tracydai1025 您好:    嘗試修改 Button5Click(.) 看看是否能符合您的需求?    
void __fastcall TForm1::Button5Click(TObject *Sender)
{
  Graphics::TBitmap *Bmp[4];      for(int i = 0; i < 4; i  )
        Bmp[i] = new Graphics::TBitmap();      Bmp[0]->Assign(Image1->Picture->Bitmap);
  Bmp[1]->Assign(Image2->Picture->Bitmap);
  Bmp[2]->Assign(Image3->Picture->Bitmap);
  Bmp[3]->Assign(Image4->Picture->Bitmap);
  Byte *ptr1,*ptr2,*ptr3,*ptr4;      int temp[4]={0};  // give the initial values      //===== added by richtop
  for (int k=0; k<4; k  )
     { Bmp[k]->PixelFormat = pf24bit;
     }
  //#####       for (int i=0;iHeight;i  )/*取值相減*/
   {
    ptr1=(Byte *)Bmp[0]->ScanLine[i];
    ptr2=(Byte *)Bmp[1]->ScanLine[i];
    ptr3=(Byte *)Bmp[2]->ScanLine[i];
    ptr4=(Byte *)Bmp[3]->ScanLine[i];
    for(int j=0;jWidth;j  )
     {
      temp[1] =abs((int)ptr1[3*j]-(int)ptr2[3*j]);
      temp[2] =abs((int)ptr1[3*j]-(int)ptr3[3*j]);
      temp[3] =abs((int)ptr1[3*j]-(int)ptr4[3*j]);
     }
   }
   int record[4] = {0, 1, 2, 3};
   int tp;       //===== added by richtop
   // to find the minimal value
   temp[0] = temp[1];
   tp = 1;
   for (int k=2; k<4;   k)
      { if ( temp[0]>temp[k] )
          { tp = k;
            temp[0] = temp[k];
          }
      }
   Image5->Picture->Assign(Bmp[record[tp]]);
   //#####
}
RichTop 敬上 =====***** 把數學當工具,可以解決問題;將數學變能力,能夠發現並解決問題! =====#####
系統時間:2024-04-25 20:15:24
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!