只有垂直翻轉1/3部分的圖 |
答題得分者是:blk5743
|
huntfox
一般會員 發表:11 回覆:13 積分:4 註冊:2006-10-23 發送簡訊給我 |
我根據"C++ Builder與影像處理"這本書寫了影像垂直翻轉的程式
可是得到的結果只有圖左邊1/3有翻轉 不知道程式出了什麼問題 請大大們幫我看一下 [code cpp] TempBitmap = new Graphics::TBitmap(); TheBitmap = Image1->Picture->Bitmap; TheBitmap->PixelFormat = pf8bit; Width = TheBitmap->Width; Height = TheBitmap->Height; TempBitmap->Assign(TheBitmap); for (int y=0; y < Height; y ){ ptr2=(Byte*) TheBitmap->ScanLine[y]; for (int x=0; x < Width; x ){ ptr1[x]=ptr2[x]; } } TheBitmap->Assign(TempBitmap); [/code] 編輯記錄
huntfox 重新編輯於 2009-01-08 15:55:17, 註解 無‧
|
blk5743
高階會員 發表:34 回覆:371 積分:236 註冊:2003-11-17 發送簡訊給我 |
你說圖只翻轉了1/3 會不會是24bits BMP你拿來做 8bits運算(8/24 = 1/3)
請試下面範例 [code cpp] void __fastcall TForm1::Button1Click(TObject *Sender) { Graphics::TBitmap *TempBitmap, *TheBitmap; BYTE *ptr1, *ptr2, bRatio; bool B8Bits = false; TempBitmap = new Graphics::TBitmap(); TheBitmap = Image1->Picture->Bitmap; if ( B8Bits ) { bRatio = 1; TheBitmap->PixelFormat = pf8bit; } else { bRatio = 3; TheBitmap->PixelFormat = pf24bit; } Width = TheBitmap->Width; Height = TheBitmap->Height; TempBitmap->Assign(TheBitmap); for (int y=0; y < Height; y ){ ptr1=(Byte*) TempBitmap->ScanLine[Height-1-y]; ptr2=(Byte*) TheBitmap->ScanLine[y]; for (int x=0; x < Width*bRatio; x ){ ptr1[x]=ptr2[x]; } } TheBitmap->Assign(TempBitmap); delete TempBitmap; } [/code] |
huntfox
一般會員 發表:11 回覆:13 積分:4 註冊:2006-10-23 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |