136 lines
4.1 KiB
Plaintext
136 lines
4.1 KiB
Plaintext
#if 0
|
|
int PASCAL WinMain(HINSTANCE hInstance,HINSTANCE /*hPrevInstance*/,LPSTR /*lpszCmdLine*/,int /*nCmdShow*/)
|
|
{
|
|
PureBitmap pureBitmap;
|
|
PureImage pureImage;
|
|
GlobalData<BYTE> bitmapBytes;
|
|
HWND hDesktopWindow;
|
|
RGB555 *pRGB555;
|
|
RGB888 *pRGB888;
|
|
RGB555 rgb555;
|
|
RGB888 rgb888;
|
|
|
|
hDesktopWindow(::GetDesktopWindow());
|
|
PureDevice pureDevice(hDesktopWindow);
|
|
pureBitmap.windowBitmap(hDesktopWindow);
|
|
if(!pureBitmap.isOkay())return 0;
|
|
pureBitmap.getBitmapBits(bitmapBytes,true);
|
|
|
|
pureImage.getBitmapInfo().rgbColors(0);
|
|
pureImage.getBitmapInfo().bitCount(BitmapInfo::Bit24);
|
|
pureImage.getBitmapInfo().width(pureBitmap.width());
|
|
pureImage.getBitmapInfo().height(-pureBitmap.height()); // make this negative when you push it in here
|
|
pureImage.getBitmapInfo().planes(1);
|
|
pureImage.getBitmapInfo().compression(BI_RGB);
|
|
pureImage.getBitmapInfo().sizeImage(0);
|
|
pureImage.getBitmapInfo().colorUsed(0);
|
|
pureImage.getBitmapInfo().colorImportant(0);
|
|
pureImage.getBitmapInfo().verifyDimensions();
|
|
pureImage.getRGBArray().size(pureImage.getBitmapInfo().width()*(-pureImage.getBitmapInfo().height()));
|
|
|
|
pRGB555=(RGB555*)(BYTE*)&bitmapBytes[0];
|
|
pRGB888=&(pureImage.getRGBArray()[0]);
|
|
for(int row=0;row<pureBitmap.height();row++)
|
|
{
|
|
for(int col=0;col<pureBitmap.width();col++)
|
|
{
|
|
rgb555=*(pRGB555+((row*pureBitmap.width())+col));
|
|
*(pRGB888+((row*pureBitmap.width())+col))=RGB888(rgb555.red(),rgb555.green(),rgb555.blue());
|
|
}
|
|
}
|
|
mhBitmap=::CreateDIBitmap((HDC)pureDevice,(BITMAPINFOHEADER*)getBitmapInfo(),CBM_INIT,&getRGBArray()[0],(BITMAPINFO*)getBitmapInfo(),DIB_RGB_COLORS);
|
|
return 0;
|
|
}
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// PureDevice compatibleDevice;
|
|
// compatibleDevice.compatibleDevice(displayDevice);
|
|
// compatibleDevice.select(pureBitmap.getBitmap());
|
|
// displayDevice.stretchBlt(Rect(0,0,640,480),compatibleDevice,Rect(0,0,pureBitmap.width(),pureBitmap.height()));
|
|
|
|
|
|
// pureImage.decode(pureBitmap.width(),pureBitmap.height(),BitmapInfo::Bit8,bitmapBytes,pureDevice);
|
|
// pureImage.draw(displayDevice);
|
|
|
|
|
|
|
|
bool PureImage::decode(int bmWidth,int bmHeight,BitmapInfo::BitsPerPixel bitsPerPixel,GlobalData<BYTE> &bitmapBytes,PureDevice &pureDevice)
|
|
{
|
|
RGB555 *pRGB555;
|
|
RGB888 *pRGB888;
|
|
RGB555 rgb555;
|
|
RGB888 rgb888;
|
|
|
|
destroy();
|
|
getBitmapInfo().rgbColors(0);
|
|
getBitmapInfo().bitCount(BitmapInfo::Bit24);
|
|
getBitmapInfo().width(bmWidth);
|
|
getBitmapInfo().height(bmHeight);
|
|
getBitmapInfo().planes(1);
|
|
getBitmapInfo().compression(BI_RGB);
|
|
getBitmapInfo().sizeImage(0);
|
|
getBitmapInfo().colorUsed(0);
|
|
getBitmapInfo().colorImportant(0);
|
|
getBitmapInfo().verifyDimensions();
|
|
getRGBArray().size(bmWidth*bmHeight);
|
|
pRGB555=(RGB555*)(BYTE*)&bitmapBytes[0];
|
|
pRGB888=&getRGBArray()[0];
|
|
|
|
for(int row=0;row<bmHeight;row++)
|
|
{
|
|
for(int col=0;col<bmWidth;col++)
|
|
{
|
|
rgb555=*(pRGB555+((row*bmWidth)+col));
|
|
RGB888 rgb888(rgb555.red(),rgb555.green(),rgb555.blue());
|
|
// RGB888 rgb888(255,0,0);
|
|
*(pRGB888+((row*bmWidth)+col))=rgb888;
|
|
}
|
|
}
|
|
mhBitmap=::CreateDIBitmap((HDC)pureDevice,(BITMAPINFOHEADER*)getBitmapInfo(),CBM_INIT,&getRGBArray()[0],(BITMAPINFO*)getBitmapInfo(),DIB_RGB_COLORS);
|
|
return mhBitmap?true:false;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 0x00007C00 red (0000 0000 0000 0000 0111 1100 0000 0000)
|
|
// 0x000003E0 green (0000 0000 0000 0000 0000 0011 1110 0000)
|
|
// 0x0000001F blue (0000 0000 0000 0000 0000 0000 0001 1111)
|
|
|
|
|
|
|
|
|
|
int windowWidth(320);
|
|
int windowHeight(200);
|
|
PureBitmap pureBitmap;
|
|
RawImage rawImage;
|
|
GlobalData<BYTE> bitmapBytes;
|
|
HWND hDesktopWindow;
|
|
|
|
hDesktopWindow=::GetDesktopWindow();
|
|
PureDevice pureDevice(hDesktopWindow);
|
|
pureBitmap.windowBitmap(hDesktopWindow);
|
|
if(!pureBitmap.isOkay())return 0;
|
|
pureBitmap.getBitmapBits(bitmapBytes,BitmapInfo::Bit24,true);
|
|
|
|
HWND hWnd=::CreateWindow("BUTTON","",WS_VISIBLE|WS_POPUP|WS_BORDER,CW_USEDEFAULT,CW_USEDEFAULT,windowWidth,windowHeight,(HWND)0,(HMENU)0,::GetModuleHandle(0),0);
|
|
if(!hWnd)return 0;
|
|
::ShowWindow(hWnd,SW_SHOW);
|
|
::UpdateWindow(hWnd);
|
|
PureDevice displayDevice(hWnd);
|
|
|
|
|
|
rawImage.width(pureBitmap.width());
|
|
rawImage.height(pureBitmap.height());
|
|
rawImage.setRawData(bitmapBytes);
|
|
rawImage.stretch(displayDevice,Point(windowWidth,windowHeight));
|
|
|
|
|
|
::Sleep(1000);
|