User manual - JPEGライブラリマニュアルver.1.10(2012年3月29日)

21
// ..........
case WM_PAINT:
hdc = BeginPaint( hWnd, &ps );
ShowBitmap( hWnd, hdc, &g_Bitmap );
EndPaint( hWnd, &ps );
break;
}
return FALSE;
}
int ShowBitmap( HWND hWnd, HDC hDC, LPBITMAP bm )
{
BITMAPINFOHEADER InfoHeader;
RECT rec;
double width_tmp;
double height_tmp;
int ShowLine;
// Makes the header of image information
InfoHeader.biSize = (DWORD)sizeof( BITMAPINFOHEADER );
InfoHeader.biWidth = bm->bmWidth;
InfoHeader.biHeight = bm->bmHeight;
InfoHeader.biPlanes = bm->bmPlanes;
InfoHeader.biBitCount = bm->bmBitsPixel;
InfoHeader.biCompression = 0;
InfoHeader.biSizeImage = 0;
InfoHeader.biXPelsPerMeter = 0;
InfoHeader.biYPelsPerMeter = 0;
InfoHeader.biClrUsed = 0;
InfoHeader.biClrImportant = 0;
//Display position calculation
GetClientRect( hWnd, &rec );
width_tmp = rec.right - 20;
height_tmp = width_tmp / ( bm->bmWidth / bm->bmHeight);
// Show the Image
ShowLine = StretchDIBits( hDC, 10, 30, ( int)width_tmp, ( int)height_tmp,
0, 0, bm->bmWidth, bm->bmHeight, bm->bmBits, ( LPBITMAPINFO)&InfoHeader,
DIB_RGB_COLORS, SRCCOPY);
return ShowLine;
}