×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

HBITMAP & dimensions of the bitmap

HBITMAP & dimensions of the bitmap

HBITMAP & dimensions of the bitmap

(OP)
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.

Nosferatu
We are what we eat...
There's no such thing as free meal...
once stated: methane@personal.ro

RE: HBITMAP & dimensions of the bitmap

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <iostream>
#include <string>

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

       std::cout << "Enter path to bitmap:";
       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 << "Bitmap not found.\n" <<
            std::endl;
            exit( 0 );
         }
         GetObject( hBitmap,sizeof( BITMAP ),
                    &bitmapInfo );

         std::cout << "Your bitmap is "  << bitmapInfo.bmWidth
                   << "x"                << bitmapInfo.bmHeight
                   << " at "             << bitmapInfo.bmBitsPixel
                   << " bits per pixel." << 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

RE: HBITMAP & dimensions of the bitmap

(OP)
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...

Nosferatu
We are what we eat...
There's no such thing as free meal...
once stated: methane@personal.ro

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close