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

攝影機攝取的bitmap图片不能正确的二值转换

尚未結案
luka228hot
一般會員


發表:7
回覆:1
積分:1
註冊:2005-09-08

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-09-27 20:58:55 IP:193.174.xxx.xxx 未訂閱
攝影機攝取的bitmap图片不能正确的二值转换,无论比较值定为多少,都不行。 原码, void __fastcall TForm1::FormCreate(TObject *Sender) {  bitmap1=new Graphics ::TBitmap;     try{         bitmap1->LoadFromFile("Bild.bmp");         bitmap1->PixelFormat=pf8bit;         }  catch(...)      {         ShowMessage("Could not load  bitmap");      }  Image1->Canvas->FillRect(Image1->Canvas->ClipRect);  Image1->Canvas->Draw(0,0,bitmap1);    }    void __fastcall TForm1::FormDestroy(TObject *Sender) { delete bitmap1;    }    void __fastcall TForm1::Button1Click(TObject *Sender) {   Image1->Canvas->FillRect(Image1->Canvas->ClipRect);       Palette(Image1);   for(int y=0;yHeight;y ) { ptr=static_cast( bitmap1->ScanLine[y]); for(int x=0;xWidth;x ) { if(ptr[x]>=220) ptr[x]=255; else ptr[x]=0; } } Image1->Picture->Bitmap->Assign(bitmap1); } void __fastcall TForm1::Palette(TImage *Pic) { LOGPALETTE* plLogPal = NULL; int ilPaletteSize = 0; // Size of the buffer for the LOGPALETTE struct Pic->Picture->Bitmap->PixelFormat = pf8bit; try { // Calculate the Memory for the Pallet and allocate memory: ilPaletteSize = sizeof(LOGPALETTE) (sizeof(PALETTEENTRY) * 255); plLogPal = (LOGPALETTE*) malloc(ilPaletteSize); if(plLogPal != NULL) { // Pallet init plLogPal->palVersion = 0x300; plLogPal->palNumEntries = 256; // Init the color in the pallet with gray value: for (int ilColorIndex = 0; ilColorIndex <= 255; ilColorIndex ) { plLogPal->palPalEntry[ilColorIndex].peRed = ilColorIndex; plLogPal->palPalEntry[ilColorIndex].peGreen = ilColorIndex; plLogPal->palPalEntry[ilColorIndex].peBlue = ilColorIndex; plLogPal->palPalEntry[ilColorIndex].peFlags = PC_NOCOLLAPSE; } // Create pallet and assign: HPALETTE hLogPal = CreatePalette(plLogPal); if (hLogPal) { Pic->Picture->Bitmap->Palette = hLogPal; } // Free the memory free(plLogPal); plLogPal = NULL; } } catch ( ... ) { } } 不知错在哪里Ä 原图;
luka228hot
一般會員


發表:7
回覆:1
積分:1
註冊:2005-09-08

發送簡訊給我
#2 引用回覆 回覆 發表時間:2005-09-27 21:12:19 IP:193.174.xxx.xxx 未訂閱
原图; 现图;
taishyang
站務副站長


發表:377
回覆:5490
積分:4563
註冊:2002-10-08

發送簡訊給我
#3 引用回覆 回覆 發表時間:2005-09-28 00:33:10 IP:218.168.xxx.xxx 未訂閱
您好:    PO程式碼的方式與版規說明請參考下面連結,煩請修改謝謝您的配合 >
系統時間:2024-04-29 0:43:25
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!