| | |
LoadImage() to bit array
Please support our Game Development advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jan 2008
Posts: 84
Reputation:
Solved Threads: 1
I posted this question in the regular C++ forum and havn't gotten any answers.
hoping I will have better luck here, here was the question:
http://www.daniweb.com/forums/thread160790.html
I need to load a bitmap from file, and get an array of bits that I cain use.
I have used CreateDIBSection() to create a backbuffer for the screen.
my array is
UINT *pBits;
I need to load the bitmap so that I can go like this:
pBits[bit] = pLoadedBitmap[bit];
I am trying to get it to work like this right now:
can anyone help?
hoping I will have better luck here, here was the question:
http://www.daniweb.com/forums/thread160790.html
I need to load a bitmap from file, and get an array of bits that I cain use.
I have used CreateDIBSection() to create a backbuffer for the screen.
my array is
UINT *pBits;
I need to load the bitmap so that I can go like this:
pBits[bit] = pLoadedBitmap[bit];
I am trying to get it to work like this right now:
HBITMAP hTexture;
BYTE *pBitData;
BITMAPINFO bmInfo;
BITMAP gBitmap;
hTexture = (HBITMAP)LoadImage(0, "texture.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_DEFAULTSIZE);
GetObject(hTexture, sizeof(BITMAP), (LPVOID)&gBitmap);
bmInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmInfo.bmiHeader.biWidth = gBitmap.bmWidth;
bmInfo.bmiHeader.biHeight = gBitmap.bmHeight;
bmInfo.bmiHeader.biPlanes = 1;
bmInfo.bmiHeader.biBitCount = gBitmap.bmPlanes * gBitmap.bmBitsPixel;
bmInfo.bmiHeader.biCompression = BI_RGB;
bmInfo.bmiHeader.biSizeImage = gBitmap.bmWidth * gBitmap.bmHeight;
bmInfo.bmiHeader.biXPelsPerMeter = 0;
bmInfo.bmiHeader.biYPelsPerMeter = 0;
bmInfo.bmiHeader.biClrUsed = 0;
bmInfo.bmiHeader.biClrImportant = 0;
pBitData = new BYTE[bmInfo.bmiHeader.biSizeImage];
GetDIBits(0, hTexture, 0, 0, pBitData, &bmInfo, DIB_RGB_COLORS);
//when I do somdething like this:
for(int n = 0; n < bmInfo.bmiHeader.biSizeImage; n++
pBits[n] = pBitData[n];
//all I get is a mess of blue pixels that seems to be random. Last edited by VBNick; Dec 5th, 2008 at 4:52 pm. Reason: forgot to post the code
•
•
Join Date: Jan 2008
Posts: 84
Reputation:
Solved Threads: 1
fixed it...
GetDIBits wouldnt work without also attaching the bitmap to an HDC
first.
also, I used this struct, with sizeof(struct) = 4
which is very convenient because I will add alpha blending later.
struct BGR
{
BYTE B;
BYTE G;
BYTE R;
BYTE p
;typedef BGR *pBGR;
pBGR pBitData = new BGR[gBitmap.bmWidth * 4 * gBitmap.bmHeight];
GetDIBits wouldnt work without also attaching the bitmap to an HDC
first.
also, I used this struct, with sizeof(struct) = 4
which is very convenient because I will add alpha blending later.
struct BGR
{
BYTE B;
BYTE G;
BYTE R;
BYTE p
;typedef BGR *pBGR;
pBGR pBitData = new BGR[gBitmap.bmWidth * 4 * gBitmap.bmHeight];
![]() |
Other Threads in the Game Development Forum
- Previous Thread: Pdcurses help
- Next Thread: learning procedural animation
Views: 810 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for Game Development
3d advertising ai algorithm ban c++ cambridge camera censorship china competition console development engine fov fpx game gamedevelopment gameprogramming gamer games gaming gauntanamo government graphics idaho in-gameadvertisement intel intellectualproperty l-systems laracroft larrabee lindenmayer live manhunt math mathematics matrix mercenaries microsoft mmorpg modded modern-warfare msn multicore naked news nintendo obama opengl palin physics pirate playstation politics processor projection ps3 rpg search selection software sony spooks spy stephenhawking stocks studio technology terrorism tombraider uk videogame web wii world-of-warcraft xbox xbox-live xbox360





