User manual - イメージャライブラリマニュアルver.1.06(2012年3月29日)

Table Of Contents
240
return FALSE;
}
}
HPALETTE SetPalette( void)
{
int i;
LOGPALETTE *lpPal;
HPALETTE hp;
lpPal = ( LOGPALETTE *)VirtualAlloc( NULL,
sizeof(WORD)*2 + 256*sizeof(PALETTEENTRY), MEM_COMMIT, PAGE_READWRITE);
lpPal->palVersion = 0x300;
lpPal->palNumEntries = 256;
// 256 階調グレースケールカラーパレット作成
for( i=0; i<256; i++)
{
lpPal->palPalEntry[i].peRed = i;
lpPal->palPalEntry[i].peGreen = i;
lpPal->palPalEntry[i].peBlue = i;
}
hp = CreatePalette( lpPal );
VirtualFree( lpPal, 0, MEM_RELEASE);
return hp;
}
VOID ShowImage( HWND hWnd, LPBYTE ImageBuffer, int dwWidth, int dwHeight )
{
HBITMAP hBmp, hOrgBmp;
HDC hdcMem, hdc;
hdc = GetDC( hWnd );
hBmp = CreateBitmap( dwWidth, dwHeight, 1, 8, ImageBuffer ); // 8bit Bitmap
hdcMem = CreateCompatibleDC( hdc );
// カラーパレット指定
SelectPalette( hdcMem, g_hPalette, FALSE );
RealizePalette( hdcMem );
hOrgBmp = ( HBITMAP )SelectObject( hdcMem, hBmp );
BitBlt( hdc, 60, 100, dwWidth, dwHeight, hdcMem, 0, 0, SRCCOPY );
SelectObject( hdcMem, hOrgBmp );
DeleteObject( hBmp );
DeleteDC( hdcMem );
ReleaseDC( hWnd, hdc );
}