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

只有垂直翻轉1/3部分的圖

答題得分者是:blk5743
huntfox
一般會員


發表:11
回覆:13
積分:4
註冊:2006-10-23

發送簡訊給我
#1 引用回覆 回覆 發表時間:2009-01-08 15:52:57 IP:118.233.xxx.xxx 訂閱
我根據"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

發送簡訊給我
#2 引用回覆 回覆 發表時間:2009-01-09 11:50:13 IP:60.251.xxx.xxx 訂閱
你說圖只翻轉了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

發送簡訊給我
#3 引用回覆 回覆 發表時間:2009-01-09 14:29:40 IP:140.123.xxx.xxx 訂閱
真的像您所說的
我只是單純的把一張圖拿來轉
不知道還有這樣的學問在裡面
學到了
感謝您
系統時間:2024-04-24 17:57:22
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!