I'm triying to create a bitmap in win32 from the Textures or images from irrlicht from some code i found here.
No success for now. Only a black square.
Any help is appreciated
Thanks
Code: Select all
video::IImage* img = device->getVideoDriver()->createImageFromFile(...);
int x_dim = (int) img->getDimension().Width;
int y_dim = (int) img->getDimension().Height;
HDC hDC = ::GetDC( NULL );
HDC hdc = CreateCompatibleDC( hDC );
HBITMAP hbm = CreateCompatibleBitmap( hdc, x_dim , y_dim );
HBITMAP hbm_tmp = (HBITMAP)SelectObject(hdc, hbm);
unsigned x, y;
for (y = 0; y < y_dim; ++y)
for (x = 0; x < x_dim; ++x)
{
video::SColor pixel = img->getPixel(x, y);
COLORREF clr;
clr = ((pixel.color & 0x000000ff) << 16) |
((pixel.color & 0x0000ff00)) |
((pixel.color & 0x00ff0000) >> 16);
SetPixel(hdc, x, y,clr);
}