線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:765
推到 Plurk!
推到 Facebook!

請問各位前輩檔案處理問題

尚未結案
ayuen
一般會員


發表:19
回覆:34
積分:10
註冊:2003-07-31

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-10-06 21:33:15 IP:219.68.xxx.xxx 未訂閱
請問各位前輩: 以下為我要將其反白的區塊 但是為何無反白 而且會出現全白ㄋ  
 Byte *ptr;
 int X,Y;   //紀錄滑鼠位置
 Graphics::TBitmap *bmpDst=new Graphics::TBitmap;
 bmpDst->Width=256;
 bmpDst->Height=256;
 bmpDst->Canvas->CopyMode=cmSrcCopy;
 bmpDst->Canvas->CopyRect(Rect(0,0,bmpDst->Width,bmpDst->Height),
                           Image1->Canvas,Rect(X,Y,X 256,Y 256));
//---------以下為將其作反白效果之處-----------
  for (int y=0;yHeight ;y  )
 {
  ptr=(Byte*)bmpDst->ScanLine[y];
  for (int x=0;xWidth;x  )
    ptr[x]=(Byte)(255-ptr[x]);
 }
  Image2->Picture->Assign(bmpDst);
  delete bmpDst;
 
taishyang
站務副站長


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

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-10-06 22:43:25 IP:140.135.xxx.xxx 未訂閱
ayuen您好: 試試改成下面這樣
Byte *ptr;
 int X,Y;   //紀錄滑鼠位置
 Graphics::TBitmap *bmpDst=new Graphics::TBitmap;
 bmpDst->Width=256;
 bmpDst->Height=256;
 bmpDst->Canvas->CopyMode=cmSrcCopy;
 bmpDst->Canvas->CopyRect(Rect(0,0,bmpDst->Width,bmpDst->Height),
                           Image1->Canvas,Rect(X,Y,X 256,Y 256));
//---------以下為將其作反白效果之處-----------
bmpDst->PixelFormat=pf8bit;
 for (int y=0;yHeight ;y  )
 {
  ptr=(Byte*)bmpDst->ScanLine[y];
  for (int x=0;xWidth;x  )
    ptr[x]=(Byte)(255-ptr[x]);
 }
  Image2->Picture->Assign(bmpDst);
  delete bmpDst;
順心 <>~我也是在學習的階段,回答的不好請您多多見諒與指教~
ayuen
一般會員


發表:19
回覆:34
積分:10
註冊:2003-07-31

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-10-06 23:36:16 IP:219.68.xxx.xxx 未訂閱
Taishyang版主你好: 怎麼會...變全黑的 阿 是抓錯值嗎
taishyang
站務副站長


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

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-10-06 23:56:23 IP:140.135.xxx.xxx 未訂閱
ayuen您好:  在我這邊不會耶,如下圖所示 Source 反白後影像 順心 <>~我也是在學習的階段,回答的不好請您多多見諒與指教~
ayuen
一般會員


發表:19
回覆:34
積分:10
註冊:2003-07-31

發送簡訊給我
#5 引用回覆 回覆 發表時間:2003-10-07 00:45:35 IP:219.68.xxx.xxx 未訂閱
Taishyang版主你好: 以下為我的顯示結果 但是為何image2只有做1/3的處理ㄋ 之前以別的方式也是會這樣 一直搞不懂能否請版主大哥解疑一下    img]http://delphi.ktop.com.tw/loadfile.php?TOPICID=12059277&CC=269703[/img]  
 
 Byte *ptr;
 Graphics::TBitmap *bmpDst=new Graphics::TBitmap;
 bmpDst->Width=256;
 bmpDst->Height=256;
 bmpDst->Canvas->CopyMode=cmSrcCopy;
 bmpDst->Canvas->CopyRect(Rect(0,0,bmpDst->Width,bmpDst->Height),
                           Image1->Canvas,Rect(X,Y,X 256,Y 256));
//---------以下為將其作反白效果之處-----------
bmpDst->PixelFormat=pf24bit;
 for (int y=0;yHeight ;y  )
 {
  ptr=(Byte*)bmpDst->ScanLine[y];
  for (int x=0;xWidth;x  )
    ptr[x]=(Byte)(255-ptr[x]);
 }
  Image2->Picture->Assign(bmpDst);
  delete bmpDst;
ayuen
一般會員


發表:19
回覆:34
積分:10
註冊:2003-07-31

發送簡訊給我
#6 引用回覆 回覆 發表時間:2003-10-07 01:54:30 IP:219.68.xxx.xxx 未訂閱
我將其改成以下方式就行摟 < class="code"> Byte *ptr; Graphics::TBitmap *bmpDst=new Graphics::TBitmap; bmpDst->Width=256; bmpDst->Height=256; bmpDst->Canvas->CopyMode=cmSrcCopy; bmpDst->Canvas->CopyRect(Rect(0,0,bmpDst->Width,bmpDst->Height), Image1->Canvas,Rect(X,Y,X 256,Y 256)); //---------以下為將其作反白效果之處----------- bmpDst->PixelFormat=pf24bit; for (int y=0;yHeight ;y ) { ptr=(Byte*)bmpDst->ScanLine[y]; for (int x=0;xWidth;x ) ptr[x*3]=ptr[x*3 1]=ptr[x*3 2]=(Byte)(255-ptr[x*3]); } Image2->Picture->Assign(bmpDst); delete bmpDst; 謝謝Taishyang版主不厭其煩的教導
系統時間:2024-05-18 19:02:01
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!