heres how i get the console HDC:
Code:
//getting the HDC Console Window:
HDC WindowHDC=GetDC(GetConsoleWindow());
works fine, because the SetPixel() draw the right pixel.
heres my actual image class:
Code:
class image{
public:
BITMAP bitmap;
HBITMAP hBitmap;
HDC hdcMem;
HDC oldBitmap;
image()
{
hdcMem = CreateCompatibleDC(GetDC(NULL));
oldBitmap =(HDC) SelectObject(hdcMem, hBitmap);
}
~image()
{
SelectObject(hdcMem, oldBitmap);
DeleteDC(hdcMem);
}
void FromFile(string strFile)
{
hBitmap = (HBITMAP)LoadImage(GetModuleHandle(NULL),
strFile.c_str(),IMAGE_BITMAP,LR_DEFAULTSIZE,LR_DEFAULTSIZE,LR_LOADFROMFILE);
oldBitmap =(HDC) SelectObject(hdcMem, hBitmap);
GetObject(hBitmap, sizeof(bitmap), &bitmap);
}
void DrawImage(HDC DestinationHDC)
{
BitBlt(DestinationHDC, 0, 0, bitmap.bmWidth, bitmap.bmHeight,hdcMem, 0, 0, SRCCOPY);
//MessageBox(NULL,"error: BITBLT", to_string(GetLastError()).c_str(), MB_OK);
}
};
see these function:
Code:
void FromFile(string strFile) {
hBitmap = (HBITMAP)LoadImage(GetModuleHandle(NULL),
strFile.c_str(),IMAGE_BITMAP,LR_DEFAULTSIZE,LR_DEFAULTSIZE,LR_LOADFROMFILE);
if(hBitmap==NULL) MessageBox(NULL,"error: BITBLT", to_string(GetLastError()).c_str(), MB_OK);
i get the message box with '0'(zero).... my question: why the HBitmap is NULL?