Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HBITMAP & dimensions of the bitmap 1

Status
Not open for further replies.

Nosferatu

Programmer
Jun 9, 2000
412
0
0
RO
Hey there...

I am fighting my way here to find some function or something that would get me the dimensions of a bitmap, by using its handle.

I used GetBitmapDimensionEx, but does not work on any handle, even if it is correct... As far as they say, this function works only if the W and H were set by the complementary function, SetBitmap...

I am totally lost...

What else is there???

Thanks. [red]Nosferatu[/red]
We are what we eat...
There's no such thing as free meal...
once stated: methane@personal.ro
 
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <iostream>
#include <string>

int main()
{
HBITMAP hBitmap;
BITMAP bitmapInfo;
std::string sBitmapName;

std::cout << &quot;Enter path to bitmap:&quot;;
std::getline( std::cin,sBitmapName );

ZeroMemory( &bitmapInfo,sizeof( bitmapInfo ) );
hBitmap=( HBITMAP )LoadImage( NULL,sBitmapName.c_str(),
IMAGE_BITMAP,0,0,
LR_LOADFROMFILE );

if( !hBitmap )
{
std::cout << &quot;Bitmap not found.\n&quot; <<
std::endl;
exit( 0 );
}
GetObject( hBitmap,sizeof( BITMAP ),
&bitmapInfo );

std::cout << &quot;Your bitmap is &quot; << bitmapInfo.bmWidth
<< &quot;x&quot; << bitmapInfo.bmHeight
<< &quot; at &quot; << bitmapInfo.bmBitsPixel
<< &quot; bits per pixel.&quot; << std::endl;
return 0;
}

//Grab a handle to your bitmap and use
//a BITMAP struct to hold the bitmaps
//dimensions. Pass the bitmaps handle
//and struct to GetObject(). Then use
//the proper attributes-> x,y,bpp etc...
//The following C++ code demonstrates this. Mike L.G.
mlg400@blazemail.com
 
Thanks alot!!!

As a matter of fact, I used that function a long time ago, but it seems that my RAM is affected by the time passing...

[red]Nosferatu[/red]
We are what we eat...
There's no such thing as free meal...
once stated: methane@personal.ro
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top