LoadImage() fails....
Heya,
Can''t believe that I bother you guys with such a fu*** questions, but I really can''t solve this problem.
I''m using win32 LoadImage() to load a bitmap, and everything works fine so far. But everytime I try to get the dimensions with GetBitmapsDimensionsEx() they are zero !? I mean the bitmap can be blitted with BitBlt, but I need to know the dimensions.... What a stupid problem, please help !!!
Tim
Tim--------------------------glvelocity.gamedev.netwww.gamedev.net/hosted/glvelocity
Why don''t you try the GetBitmap function? GetBitmapDimensionEx says that that the dimensions of the bitmap must be set with SetBitmapDimensionEx in order to return the size. The GetBitmap function accepts the BITMAP structure as a parameter. You can then use BITMAP.bmWidth and BITMAP.bmHeight.
There is no function like "GetBitmap()" in win32...
But what is this for a strange os ? I mean you can load a bitmap but you can''t retrieve its size ???
But what is this for a strange os ? I mean you can load a bitmap but you can''t retrieve its size ???
Tim--------------------------glvelocity.gamedev.netwww.gamedev.net/hosted/glvelocity
Hey, send me the code and i''ll see what i can do. I''ve been working with win23 API and the blitting images functions and whatnot, i''m at king171@hotmail.com ...
- king171@hotmail.com
- http://www.cfxweb.net/mxf/
- king171@hotmail.com
- http://www.cfxweb.net/mxf/
If im not mistaken, theres a function that allows you to get info on a bitmap into a BITMAP structure, and this BITMAP structure contains the width. Ive done it before in Win32, so ill get back to you.
=======================================
A man with no head is still a man.
A head with no man is plain freaky.
=======================================
A man with no head is still a man.
A head with no man is plain freaky.
Hi,
I''m try to explain what I want to do..
I want to load a BMP (or "DIB") and display it with BitBlt. No problem so far. But I want to have acess to the bits, this is very important. Since GetBitmapBits() is "obsolete" (in win32 this means it is replaced by a slower and more complicated function) I want to use GetDIBits().
I''m working with win32 for several years, using it in vb to c++. But I just can''t understand why such a simple stuff like loading a bitmap can take up 200 pages in "programming windows". I guess even writing my own loading and drawing functions might be faster than understanding this completely broken API... Or can anyone give me a code snippet that loads a DIB and give me access to the bits. And DIBs can''t be displayed using BitBlt right ?
10 minutes to solve the problem, 500 hours to code a win32 app around it...
TIm
I''m try to explain what I want to do..
I want to load a BMP (or "DIB") and display it with BitBlt. No problem so far. But I want to have acess to the bits, this is very important. Since GetBitmapBits() is "obsolete" (in win32 this means it is replaced by a slower and more complicated function) I want to use GetDIBits().
I''m working with win32 for several years, using it in vb to c++. But I just can''t understand why such a simple stuff like loading a bitmap can take up 200 pages in "programming windows". I guess even writing my own loading and drawing functions might be faster than understanding this completely broken API... Or can anyone give me a code snippet that loads a DIB and give me access to the bits. And DIBs can''t be displayed using BitBlt right ?
10 minutes to solve the problem, 500 hours to code a win32 app around it...
TIm
Tim--------------------------glvelocity.gamedev.netwww.gamedev.net/hosted/glvelocity
HBITMAP hbm;
BITMAP bm;
hbm = (HBITMAP) LoadImage(NULL, szBitmap, IMAGE_BITMAP,
0, 0, LR_LOADFROMFILE / LR_CREATEDIBSECTION);
if (hbm == NULL)
return NULL;
//
// Get size of the bitmap
//
GetObject(hbm, sizeof(bm), &bm);
bm.bmWidth and bm.bmHeight are the bitmaps dimensions.
---
Rob
See other worlds at http://www.silverfrost.com
---RobSee other worlds at http://www.silverfrost.com
Thanks, but I already managed to get that far. Now I only need a linear array of bytes that conatins the image. I can''t get GetDIBits() working... Please help again ;-)))
And some one said that 3D coding is hard...
And some one said that 3D coding is hard...
Tim--------------------------glvelocity.gamedev.netwww.gamedev.net/hosted/glvelocity
I''m thinkin of a solution where I
a.) Load the image myself and use CreateBitmapIndirect() to get my bitmap for blitting
b.) Use the win32 functions to load the bitmap and get the bits back from it...
any code ? thanks
a.) Load the image myself and use CreateBitmapIndirect() to get my bitmap for blitting
b.) Use the win32 functions to load the bitmap and get the bits back from it...
any code ? thanks
Tim--------------------------glvelocity.gamedev.netwww.gamedev.net/hosted/glvelocity
You wanna use GetDIBits(0;? THen use it! :
=======================================
A man with no head is still a man.
A head with no man is plain freaky.
quote: GetDIBits
The GetDIBits function retrieves the bits of the specified bitmap and copies them into a buffer using the specified format.
int GetDIBits( HDC hdc,
// handle of device context
HBITMAP hbmp,
// handle of bitmap
UINT uStartScan,
// first scan line to set in destination bitmap
UINT cScanLines,
// number of scan lines to copy
LPVOID lpvBits,
// address of array for bitmap bits
LPBITMAPINFO lpbi,
// address of structure with bitmap data
UINT uUsage
// RGB or palette index
);
Parameters
hdc
Identifies the device context.
hbmp
Identifies the bitmap.
uStartScan
Specifies the first scan line to retrieve.
cScanLines
Specifies the number of scan lines to retrieve.
lpvBits
Points to a buffer to receive the bitmap data. If this parameter is NULL, the function passes the dimensions and format of the bitmap to the BITMAPINFO structure pointed to by the lpbi parameter.
lpbi
Points to a BITMAPINFO structure that specifies the desired format for the device-independent bitmap (DIB) data.
uUsage
Specifies the format of the bmiColors member of the BITMAPINFO structure. It must be one of the following values: Value
Meaning
DIB_PAL_COLORS
The color table should consist of an array of 16-bit indices into the current logical palette.
DIB_RGB_COLORS
The color table should consist of literal red, green, blue (RGB) values.
=======================================
A man with no head is still a man.
A head with no man is plain freaky.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement