TCHAR *FileNames[] = {
TEXT("PIC10.BMP"),
TEXT("LION.BMP"),
TEXT("PIC6.BMP"),
NULL
};
int index = 0;
while(1)
{
TCHAR* pFileName = FileNames[index];
if( pFileName == NULL ) break;
printf("Test Graphic %s\n",pFileName);
HBITMAP hbmp = NULL;
HDC hdc = NULL;
do
{
hbmp = (HBITMAP)LoadImage(NULL,pFileName,IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
if( hbmp == INVALID_HANDLE_VALUE ) break;
HDC hdc = CreateDC(TEXT("DISPLAY"),NULL,NULL,NULL);
if (hdc == NULL) break;
BITMAPINFO BMPInfo;
memset(&BMPInfo,0,sizeof(BMPInfo));
BMPInfo.bmiHeader.biSize = sizeof(BMPInfo);
int r = GetDIBits(hdc,hbmp,0,0,NULL,&BMPInfo,DIB_RGB_COLORS);
if( r == 0 ) break;
printf(" biSize %d/%d\n",BMPInfo.bmiHeader.biSize,sizeof(BMPInfo));
printf(" biSizeImage %d\n",BMPInfo.bmiHeader.biSizeImage);
printf(" biWidth %d\n",BMPInfo.bmiHeader.biWidth);
printf(" biHeight %d\n",BMPInfo.bmiHeader.biHeight);
printf(" biBitCount %d\n",BMPInfo.bmiHeader.biBitCount);
printf(" biPlanes %d\n",BMPInfo.bmiHeader.biPlanes);
printf(" biClrUsed %d\n",BMPInfo.bmiHeader.biClrUsed);
if( BMPInfo.bmiHeader.biPlanes != 1 ) break;
if( BMPInfo.bmiHeader.biHeight != 64 ) break;
if( BMPInfo.bmiHeader.biWidth != 128 ) break;
if( BMPInfo.bmiHeader.biBitCount != 1
&& BMPInfo.bmiHeader.biBitCount != 24
&& BMPInfo.bmiHeader.biBitCount != 32 ) break;
int BMPInfoSize = sizeof(BITMAPINFOHEADER);
if( BMPInfo.bmiHeader.biCompression == BI_BITFIELDS ) BMPInfoSize += 12;
else BMPInfoSize += BMPInfo.bmiHeader.biClrUsed * sizeof(RGBQUAD);
BITMAPINFO* pBMPInfo = (BITMAPINFO*) ( new BYTE[BMPInfoSize] );
if( pBMPInfo != NULL )
{
*pBMPInfo = BMPInfo;
}
BYTE* pBuffer = new BYTE[BMPInfo.bmiHeader.biSizeImage];
if( pBuffer != NULL )
{
memset(pBuffer,0,BMPInfo.bmiHeader.biSizeImage);
r = GetDIBits(hdc,hbmp,0,64,pBuffer,pBMPInfo,DIB_RGB_COLORS);
printf( " GetDIBits %d\n",r);
PSUC_Frame2LCD(
handle,pBuffer,BMPInfo.bmiHeader.biSizeImage);
}
}
while(0);
if( hbmp != NULL ) CloseHandle(hbmp);
if( hdc != NULL ) CloseHandle(hdc);
index += 1;
Sleep(5000);
}