標題:
GDI+不同的地方
[打印本頁]
作者:
bibi
時間:
2015-4-18 20:39
標題:
GDI+不同的地方
研究了GDI+處理圖像的地方,發(fā)現(xiàn)它一些與眾不同的地方,被它坑了一天。。。。。
1、GDI+的像素的原點默認你在左下角的,所以讀取像素的順序是從最低一行開始的(bottom-left),其他一般的圖像處理軟件,像Photoshop,OpenCV、FreeImage什么的都是在左上角的(top-left)。
2、GDI+生成的二值圖像也與其他的不同,它用0表示黑色,非0(比特1)表示白色,二其他的像Photoshop恰恰相反的。就是說BW位圖的頭文件調色板相反的。
3、其他, 可以二值圖像的調色板的兩種顏色可以隨意的進行替換,比如把比特0替換成白色,表示沒有,比特1替換成紅色。
附:下面的函數(shù)可以GDI+ Bitmap、Image的調色板
// 修改調色板的函數(shù)
void ResetPalette(Bitmap *pBitmap)
{
if(!pBitmap)
return;
// Modify Palette
UINT size = pBitmap->GetPaletteSize();
TRACE1("The size of the palette is %d bytes.\n", size);
ColorPalette *ppal = (ColorPalette*)malloc(size);
pBitmap->GetPalette(ppal, size);
// Debug Palette
if(size > 0)
{
TRACE1("There are %u colors in the palette.\n", ppal->Count);
for(UINT j = 0; j < ppal->Count; ++j)
TRACE1("0x%x\n", ppal->Entries[j]);
}
// Reset Palette
ppal->Entries[0] = Color::MakeARGB(0xff,0xff,0xff,0xff);
ppal->Entries[1] = Color::MakeARGB(0xff, 0xff,0x00,0x00);
pBitmap->SetPalette(ppal);
free(ppal);
}
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1