寫影像處理之像素值不對? |
答題得分者是:mieng
|
yangkissktop
一般會員 發表:13 回覆:29 積分:8 註冊:2003-10-25 發送簡訊給我 |
請各位高手:
1.先在小畫家建立屬性大小為2x2之圖片:
黑白
白黑
2.在BCB拖一OpenPictureDialog
3.及一個2x2之TImage
4.程式碼如下:
Graphics::TBitmap *bitmap;
if( FileExists(OpenPictureDialog1->FileName) )
{
Image1->Picture->LoadFromFile( OpenPictureDialog1->FileName );
// Image1->Picture->Bitmap->PixelFormat = pf24bit;
bitmap = new Graphics::TBitmap();
// bitmap->PixelFormat = pf24bit;
bitmap->Width = 2;
bitmap->Height = 2;
bitmap->Canvas->CopyRect(Rect(0,0, 1,1), Image1->Picture->Bitmap->Canvas, Rect(0,0, 1,1));
// bitmap->Canvas->StretchDraw(TRect(0,0, 1,1), Image1->Picture->Bitmap); Byte *pixel;
for(int y=0 ; y
------
yangkissktop |
mieng
中階會員 發表:12 回覆:97 積分:81 註冊:2003-10-31 發送簡訊給我 |
Graphics::TBitmap *bitmap; if(FileExists(OpenPictureDialog1->FileName)) { Image1->Picture->LoadFromFile(OpenPictureDialog1->FileName); // Image1->Picture->Bitmap->PixelFormat = pf24bit; bitmap = new Graphics::TBitmap(); // bitmap->PixelFormat = pf24bit; bitmap->Width = 2; bitmap->Height = 2; bitmap->Canvas->CopyRect(Rect(0,0, 2,2), Image1->Picture->Bitmap->Canvas, Rect(0,0, 2,2)); // bitmap->Canvas->StretchDraw(TRect(0,0, 1,1), Image1->Picture->Bitmap); Byte *pixel; for(int y=0 ; y < 2 ; y ){ pixel = (Byte *)bitmap->ScanLine[y]; for(int x=0 ; x <2 ; x ) { AnsiString R; R = "r:"; R = pixel[3*x 2]; AnsiString G; G = "g:"; G = pixel[3*x 1]; AnsiString B; B = "b:"; B = pixel[3*x 0]; ShowMessage( R G B ); } } } 以下為BCB的說明和範例 The following code illustrates the differences between CopyRect and BrushCopy. The bitmap graphic TARTAN.BMP?is loaded into Bitmap and displayed on the Canvas of Form1. BrushCopy replaces the color black in the graphic with the brush of the canvas, while CopyRect leaves the colors intact. Graphics::TBitmap *Bitmap; TRect MyRect, MyOther; MyRect = Rect(10,10,100,100); MyOther = Rect(10,111,100, 201); Bitmap = new Graphics::TBitmap; Bitmap->LoadFromFile("c:\\windows\\tartan.bmp"); Form1->Canvas->BrushCopy(MyRect, Bitmap, MyRect, clBlack); Form1->Canvas->CopyRect(MyOther, Bitmap->Canvas, MyRect); delete Bitmap;我想在copy時圖像大小要設大一點不要剛剛好就可以了,~~ 學習中請大家多多指導呦~~ ☆星霧☆(Mineg Chien WU) 發表人 - mieng 於 2003/12/03 10:55:01 |
yangkissktop
一般會員 發表:13 回覆:29 積分:8 註冊:2003-10-25 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |