flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
comrade 05 Nov 2009, 07:45
You can try using GetObject (BITMAP structure), then manually processing BITMAP.bmBit, expanding each pixel from 3 bytes to 4.
Alternatively you can create a destination, 32-bit bitmap using CreateDIBitmap or CreateDIBSection, select this bitmap onto a temporary DC, and then using BitBlt to do the conversion. |
|||
![]() |
|
ass0 05 Nov 2009, 13:18
Am i wrong or the 4th byte is just alpha? Because Red, Green and Blue are one byte each.
|
|||
![]() |
|
bitshifter 05 Nov 2009, 20:21
Ok, i have come up with a simple solution with GetDIBits!
This is how to create an offscreen buffer (DIB32) and load a 24bit texture and make it DIB32 compatible. I now have a 32bit perspective texture mapper up and running. (OH FUCK YEAH!) Code: // First we need a device context that is compatible // with the desktop settings. (1024x768x32 on my PC) HDC BufferDC = CreateCompatibleDC(NULL); // Now we describle a format for the offscreen buffer. BITMAPINFO BufferInfo; ZeroMemory(&BufferInfo,sizeof(BITMAPINFO)); BufferInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); BufferInfo.bmiHeader.biWidth = GetSystemMetrics(SM_CXSCREEN); BufferInfo.bmiHeader.biHeight = GetSystemMetrics(SM_CYSCREEN); BufferInfo.bmiHeader.biPlanes = 1; BufferInfo.bmiHeader.biBitCount = 32; BufferInfo.bmiHeader.biCompression = BI_RGB; // Create a device independant bitmap for the offscreen buffer. HBITMAP BufferBitmap = CreateDIBSection( BufferDC, &BufferInfo, DIB_RGB_COLORS, (void**)&g_Buffer.first, // Store pointer to first pixel in this value. NULL,0); // No file mapping crap. // Describe the texture format. // Same as buffer format but with hardwired size. BITMAPINFO TextureInfo = BufferInfo; TextureInfo.bmiHeader.biWidth = 100; TextureInfo.bmiHeader.biHeight = 100; // Create device independant bitmap for texture. HBITMAP TextureBitmap = CreateDIBSection( BufferDC, &TextureInfo, DIB_RGB_COLORS, (void**)&g_Texture.first, // Store pointer to first pixel in this value. NULL,0); // No file mapping crap. // Load the 24bit image from file. HBITMAP hImage = (HBITMAP)LoadImage( NULL, // No HINSTANCE since its not a resource. "Image.bmp", IMAGE_BITMAP, TextureInfo.bmiHeader.biWidth, TextureInfo.bmiHeader.biHeight, LR_LOADFROMFILE); // Transfer the bitmap into the texture DIB. GetDIBits( BufferDC, hImage, 0, // First scan line. TextureInfo.bmiHeader.biHeight, // Number of scan lines. g_Texture.first, // Pointer to first pixel. &TextureInfo, // Address of BITMAPINFO with desired specs. DIB_RGB_COLORS); // Were done with the inage so... DeleteObject(hImage); // Select the buffer for rendering to. HBITMAP OldBitmap = (HBITMAP)SelectObject(BufferDC,BufferBitmap); // Dont forget to clean up later _________________ Coding a 3D game engine with fasm is like trying to eat an elephant, you just have to keep focused and take it one 'byte' at a time. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.