[問題] 圖形翻轉的程式問題
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
BCB
程式碼(Code):(請善用置底文網頁, 記得排版)
void rotate(TImage *Image1,TImage *Image2)
{
// picture2 init
Graphics::TBitmap *bmp2 = new Graphics::TBitmap();
bmp2->Width = Image1->Picture->Height;
bmp2->Height = Image1->Picture->Width;
bmp2->Canvas->Draw(0,0,Image1->Picture->Graphic);
Image2->Picture->Bitmap->Assign(bmp2);
Image2->Refresh();
delete bmp2;
Byte **ptr1, **ptr2,tmp;
int k,row,col,index;
Image1->Picture->Bitmap->PixelFormat = pf24bit;
ptr1 = new Byte*[Image1->Picture->Height];
Image2->Picture->Bitmap->PixelFormat = pf24bit;
ptr2 = new Byte*[Image2->Picture->Height];
for (k = 0; k < Image1->Picture->Height; k++) {
ptr1[k] = (Byte*) Image1->Picture->Bitmap->ScanLine[k];
}
for (k = 0; k < Image2->Picture->Height; k++) {
ptr2[k] = (Byte*) Image2->Picture->Bitmap->ScanLine[k];
}
for (row = 0; row < Image1->Picture->Height; row++) {
index = 0;
for (col = 0; col < Image1->Picture->Width; col++) {
tmp = (Byte)ptr1[row][index];
ptr2[col][row] = tmp;
tmp = (Byte)ptr1[row][index+1];
ptr2[col][row+1] = tmp;
tmp = (Byte)ptr1[row][index+2];
ptr2[col][row+2] = tmp;
index += 3;
}
}
index -= 3;
// Image2->Refresh();
delete [] ptr1;
delete [] ptr2;
}
補充說明(Supplement):
這是一個要把圖片做鏡像顯示的FUNCTION,INPUT 是張BMP圖片
但是輸出結果總是錯誤的 像是RGB給值錯誤,顏色錯掉 且圖形只有一半
請高手幫忙指點一下
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.33.231.82
推
04/10 00:10, , 1F
04/10 00:10, 1F
→
04/10 00:47, , 2F
04/10 00:47, 2F