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

[bcb][求助]有關bitmap格式圖片翻轉的問題..請大大們為我幫個忙..

尚未結案
dickyaaa
一般會員


發表:8
回覆:11
積分:3
註冊:2005-09-30

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-11-30 20:36:47 IP:211.76.xxx.xxx 未訂閱
最近我在寫一個可以將bmp的圖檔水平翻轉的程式 在執行.exe時卻出現了下面的問題 而當我在bcb下compiler時是ok的沒有什麼問題 但在compiler之後要進行view下的flip/rotate卻會出現 請問一下這是什麼問題呢 我又錯在那呢... 我的project檔案放在這個地方 http://61.60.224.22/mywebhd/get_file.aspx?name=00007142%5cpract.rar 希望大大們能為我解答 謝謝 發表人 - dickyaaa 於 2005/11/30 20:40:10
fusung
中階會員


發表:26
回覆:169
積分:99
註冊:2003-11-25

發送簡訊給我
#2 引用回覆 回覆 發表時間:2005-12-01 00:59:09 IP:140.114.xxx.xxx 未訂閱
dickyaaa, 你的檔案無法下載喔!    http://61.60.224.22/mywebhd/get_file.aspx?name=00007142\pract.rar The first step toward proving things for yourself is to understand how others have done it before!
------


The first step toward proving things for yourself is to understand how others have done it before!

dickyaaa
一般會員


發表:8
回覆:11
積分:3
註冊:2005-09-30

發送簡訊給我
#3 引用回覆 回覆 發表時間:2005-12-01 13:55:02 IP:211.76.xxx.xxx 未訂閱
不好意思.. 我重新上傳了 請大大試看看吧 http://home.tinp.net.tw/mypage/00007142/pract.rar 麻煩大大了 謝謝
fusung
中階會員


發表:26
回覆:169
積分:99
註冊:2003-11-25

發送簡訊給我
#4 引用回覆 回覆 發表時間:2005-12-01 15:30:31 IP:61.222.xxx.xxx 未訂閱
 
for (int y=0; y < Height; y  )
  {ptr1=(Byte*) TempBitmap->ScanLine[y];
   ptr2=(Byte*) TheBitmap->ScanLine[y];
   for (int x=0; x < Width; x  )
   {         ptr1[x]= ptr2[Width-1-x];
     }
// TheBitmap->Assign(TempBitmap);    ←這兩行這應該擺在for-loop外面吧!!
// delete TempBitmap;                
 }
TheBitmap->Assign(TempBitmap);   
delete TempBitmap;    
The first step toward proving things for yourself is to understand how others have done it before!
------


The first step toward proving things for yourself is to understand how others have done it before!

dickyaaa
一般會員


發表:8
回覆:11
積分:3
註冊:2005-09-30

發送簡訊給我
#5 引用回覆 回覆 發表時間:2005-12-01 21:36:24 IP:211.76.xxx.xxx 未訂閱
可以了 很感謝大大 另外想請問一下大大 要如何用一個label來顯示目前讀進來的圖的pixel 也就是類似680*240之類的 要怎麼寫呢? 麻煩大大一下 謝謝 發表人 - dickyaaa 於 2005/12/01 21:52:29
fusung
中階會員


發表:26
回覆:169
積分:99
註冊:2003-11-25

發送簡訊給我
#6 引用回覆 回覆 發表時間:2005-12-01 22:29:09 IP:61.222.xxx.xxx 未訂閱
  Label1->Caption = IntToStr(Height) + "*" + IntToStr(Width); 
ps.建議多多利用K.Top的Search Engine,可以加快解決你的問題喔!! <> <> >
------


The first step toward proving things for yourself is to understand how others have done it before!

dickyaaa
一般會員


發表:8
回覆:11
積分:3
註冊:2005-09-30

發送簡訊給我
#7 引用回覆 回覆 發表時間:2005-12-02 14:19:02 IP:211.76.xxx.xxx 未訂閱
嗯..因為之前很少在這發題所以就沒用搜尋 謝謝大大的教學 想請問一下大大 這個式子可以和我解釋一下嗎 另外.這行敘述是加在那呢 是加在label裡面嗎 為何我加在這裡面卻沒有顯示呢 麻煩一下大大為我解答上面問題 謝謝 發表人 - dickyaaa 於 2005/12/02 14:56:09 發表人 - dickyaaa 於 2005/12/02 15:08:21
fusung
中階會員


發表:26
回覆:169
積分:99
註冊:2003-11-25

發送簡訊給我
#8 引用回覆 回覆 發表時間:2005-12-02 16:02:39 IP:211.21.xxx.xxx 未訂閱
我是從BCB上面拉一個Label元件到Form1裡面,接著在下列Callback function    中插入紅色標記的部分
 
void __fastcall TForm1::fliprotate1Click(TObject *Sender)
Width=TheBitmap->Width;
Height=TheBitmap->Height;
Label1->Caption = IntToStr(Height) + "*" + IntToStr(Width);
// Caption   是Label1中的一個屬性,可以讓使用者看到不同文字內容
// IntToStr()是將整數轉成字串 
// +        是做字串相加
The first step toward proving things for yourself is to understand how others have done it before!
------


The first step toward proving things for yourself is to understand how others have done it before!

dickyaaa
一般會員


發表:8
回覆:11
積分:3
註冊:2005-09-30

發送簡訊給我
#9 引用回覆 回覆 發表時間:2005-12-02 20:46:15 IP:211.76.xxx.xxx 未訂閱
大大..我試了一下..真的可以了 但好像只能算出原始圖的那一個像素 有沒有辦法可以算出當放大或縮小時的像素呢 我怎麼試都沒辦法 想請問一下大大 麻煩大大了 謝謝
fusung
中階會員


發表:26
回覆:169
積分:99
註冊:2003-11-25

發送簡訊給我
#10 引用回覆 回覆 發表時間:2005-12-02 22:24:11 IP:61.222.xxx.xxx 未訂閱
Hi, dickyaaa:    咦!你的程式不是可以依照下拉選單選擇不同倍率縮放,來給定影像大小嗎?, 為什麼會不曉得影像大小? 還是我誤解你的意思? 我想關鍵在下拉選單的Callback function,試著從那裡去下手吧!! 如果還是不行,你把你修改的部分貼上來,我再幫你check... <> <> >
------


The first step toward proving things for yourself is to understand how others have done it before!

dickyaaa
一般會員


發表:8
回覆:11
積分:3
註冊:2005-09-30

發送簡訊給我
#11 引用回覆 回覆 發表時間:2005-12-02 23:04:29 IP:211.76.xxx.xxx 未訂閱
大大.先謝謝大大的熱心 大大..我不是指圖片的大小 而是在當我縮小時那時pixel*pixel是多少 也就是之前問的label那個 因為我都只能照原始圖的大小來顯示那個lable 我想要改成當我縮小或放大時..那個lable也會一起改變 麻煩大大幫我看看一下 謝謝
fusung
中階會員


發表:26
回覆:169
積分:99
註冊:2003-11-25

發送簡訊給我
#12 引用回覆 回覆 發表時間:2005-12-02 23:49:32 IP:140.114.xxx.xxx 未訂閱
     void __fastcall TForm1::ComboBox1Change(TObject *Sender)
{
.....省略....
Image1->Height=Image1->Picture->Bitmap->Height/S;
Label1->Caption = IntToStr(Image1->Picture->Bitmap->Height/S)   "*"   IntToStr(Image1->Picture->Bitmap->Width/S);
}
再試試看吧! <> <> >
------


The first step toward proving things for yourself is to understand how others have done it before!

dickyaaa
一般會員


發表:8
回覆:11
積分:3
註冊:2005-09-30

發送簡訊給我
#13 引用回覆 回覆 發表時間:2005-12-05 13:04:02 IP:211.76.xxx.xxx 未訂閱
前幾天因為一點事就沒回來回報...不好意思 嗯..好的.. 謝謝大大的熱心幫助.. 我去試看看..有問題就來回報大大
dickyaaa
一般會員


發表:8
回覆:11
積分:3
註冊:2005-09-30

發送簡訊給我
#14 引用回覆 回覆 發表時間:2005-12-05 13:26:12 IP:211.76.xxx.xxx 未訂閱
大大我試了一下 結果卻出現在那行卻出現了 [C Error] Unit1.cpp(108): E2015 Ambiguity between '_fastcall Sysutils::IntToStr(__int64)' and '_fastcall Sysutils::IntToStr(int)' [C Error] Unit1.cpp(108): E2015 Ambiguity between '_fastcall Sysutils::IntToStr(__int64)' 這二個錯誤 這是為何呢 麻煩大大幫我解答一下 謝謝
fusung
中階會員


發表:26
回覆:169
積分:99
註冊:2003-11-25

發送簡訊給我
#15 引用回覆 回覆 發表時間:2005-12-05 14:31:02 IP:61.222.xxx.xxx 未訂閱
原本是要回應你說的我不是指圖片的大小, 其實縮小時那時pixel*pixel就是當時圖片的大小啦! 索性直接貼上Image1->Picture->Bitmap->Width/S,沒有確認結果。 你可以用方法1:強迫轉型成AnsiString或是直接抓當時的影像大小來轉成字串,即下面方法2。
 
【方法1】
Label1->Caption = (AnsiString)(Image1->Picture->Bitmap->Width/S) + "*" + (AnsiString)(Image1->Picture->Bitmap->Height/S);
或是
【方法2】
Label1->Caption = IntToStr(Image1->Width) + "*" + IntToStr(Image1->Height);
再試試看囉 <> <> >
------


The first step toward proving things for yourself is to understand how others have done it before!

dickyaaa
一般會員


發表:8
回覆:11
積分:3
註冊:2005-09-30

發送簡訊給我
#16 引用回覆 回覆 發表時間:2005-12-05 19:43:43 IP:211.76.xxx.xxx 未訂閱
Label1->Caption = (AnsiString)(Image1->Picture->Bitmap->Width/S) + "*" + (AnsiString)(Image1->Picture->Bitmap->Height/S); 這個可以了 謝謝大大 那在請問一下大大 若我想把彩色變成灰階的話 要參考什麼呢 因為我對這方面蠻不了解的 所以 麻煩大大教我一下 謝謝
fusung
中階會員


發表:26
回覆:169
積分:99
註冊:2003-11-25

發送簡訊給我
#17 引用回覆 回覆 發表時間:2005-12-05 22:43:46 IP:140.114.xxx.xxx 未訂閱
善用K.Top的站內搜尋引擎,找找關鍵字: 灰階, RGB... The first step toward proving things for yourself is to understand how others have done it before!
------


The first step toward proving things for yourself is to understand how others have done it before!

dickyaaa
一般會員


發表:8
回覆:11
積分:3
註冊:2005-09-30

發送簡訊給我
#18 引用回覆 回覆 發表時間:2005-12-07 20:45:19 IP:211.76.xxx.xxx 未訂閱
大大..下面是我新用好的程式 也就是和上次那個差不多 只是有修改一下下 想請問一下..為何我在旋轉時..圖片會失真呢 是我那裡出了問題嗎 麻煩一下大大 http://home.tinp.net.tw/mypage/00007142/new.rar 另外
void __fastcall TForm1::Button1Click(TObject *Sender)
{
   Graphics::TBitmap *bmp24bitColor=new Graphics::TBitmap;
   Graphics::TBitmap *bmp8bitGray=new Graphics::TBitmap;       bmp24bitColor->LoadFromFile("C:\\24bit.bmp");
   bmp8bitGray->Width=bmp24bitColor->Width;
   bmp8bitGray->Height=bmp24bitColor->Height;       for(int i=0; iWidth; i  )
   {
      for(int j=0; jHeight; j  )
      {
         TColor Color=bmp24bitColor->Canvas->Pixels[i][j];
         BYTE R=GetRValue(Color);
         BYTE G=GetGValue(Color);
         BYTE B=GetBValue(Color);
         int Gray=(R G B)/3;
         Color=(TColor)RGB(Gray, Gray, Gray);
         bmp8bitGray->Canvas->Pixels[i][j]=Color;
         Application->ProcessMessages();
      }
   }
   bmp8bitGray->PixelFormat=pf8bit;
   bmp8bitGray->SaveToFile("C:\\8bit.bmp");       delete bmp8bitGray;
   delete bmp24bitColor;
}     
在紅色的地方看不太懂那是什麼意思 可以麻煩大大為我解答一下嗎 而錄色的地方若依我的程式的話..要如何去修改 問題好像蠻多的 麻煩一下大大為我解答一下 此外還想問一下 有沒有什麼書是關於c builder用在影像處理上的嗎 大大不知是不知道嗎 麻煩大大了 謝謝
fusung
中階會員


發表:26
回覆:169
積分:99
註冊:2003-11-25

發送簡訊給我
#19 引用回覆 回覆 發表時間:2005-12-08 00:35:26 IP:61.222.xxx.xxx 未訂閱
Hello, dickyaaa    關於旋轉你可以參考這2篇,相信可以解決你大部分的問題。 【圖形翻轉範例】http://delphi.ktop.com.tw/topic.php?topic_id=38783 【影像處理VI】 http://delphi.ktop.com.tw/topic.php?topic_id=40159 說到學習影像處理搭配使用c++ builder工具, 我個人建議你先把K.top影音多媒體的精華文章先瀏覽過一次, 然後試著改善別人發表的作品,那麼使用BCB來處理影像的技巧應該就會很純熟。 另外其他你問的問題,基本上都可以在站上或help手冊找的到答案,我簡略回答:
(1)Graphics::TBitmap *bmp24bitColor=new Graphics::TBitmap;
→在c++ builder工具中,將滑鼠停留在想查詢的關鍵字如TBitmap, 按一下"F1"按鍵,就可查詢到TBitmap的相關訊息 < class="code"> (2) bmp8bitGray->Width=bmp24bitColor->Width; bmp8bitGray->Height=bmp24bitColor->Height; →規劃相同的影像大小,相當於規劃一樣大的記憶體空間。
(3)  BYTE R=GetRValue(Color);
     BYTE G=GetGValue(Color);
     BYTE B=GetBValue(Color);
同問題(1),查關鍵字GetRValue, GetGValue, GetBValue
(4) Application->ProcessMessages();
→用K.top搜尋引擎找找吧< > 最後,個人衷心建議一些小問題要自己多花點時間找資料, 在>學著找資料進而自己解決問題也是很重要的, 與你共勉之< > 發表人 -
------


The first step toward proving things for yourself is to understand how others have done it before!

dickyaaa
一般會員


發表:8
回覆:11
積分:3
註冊:2005-09-30

發送簡訊給我
#20 引用回覆 回覆 發表時間:2005-12-08 19:51:27 IP:211.76.xxx.xxx 未訂閱
感謝大大不怕麻煩的為我解答 我試著先自己找一下資料 有問題的話..再來問一下大大 謝謝
系統時間:2024-04-25 22:35:38
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!