Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. size from HBITMAP

size from HBITMAP

Scheduled Pinned Locked Moved C / C++ / MFC
questionlearning
6 Posts 4 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    is there any way to get pixel size from HBITMAP? (i want to center it into rectangle) (most often it is loaded by LoadImage - maybe resource pixel size is available?) t!

    _ J M 3 Replies Last reply
    0
    • L Lost User

      is there any way to get pixel size from HBITMAP? (i want to center it into rectangle) (most often it is loaded by LoadImage - maybe resource pixel size is available?) t!

      _ Offline
      _ Offline
      _Theo_
      wrote on last edited by
      #2

      Use GetBitmapDimensionEx to get the dimensions of the bitmap.

      L 1 Reply Last reply
      0
      • _ _Theo_

        Use GetBitmapDimensionEx to get the dimensions of the bitmap.

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        but help speaks you must call set before (and it is not in pixels) t!

        1 Reply Last reply
        0
        • L Lost User

          is there any way to get pixel size from HBITMAP? (i want to center it into rectangle) (most often it is loaded by LoadImage - maybe resource pixel size is available?) t!

          J Offline
          J Offline
          John R Shaw
          wrote on last edited by
          #4

          First of all yes I know the answer, but if your are using Visual C++ and MFC, a simple search of the help sytem will give you the answer. Example: (You could write this) CSize GetSizeOfBitmap( CBitmap& MyBitmap ) { BITMAP bmp; MyBitmap.GetBitmap(&bmp); return CSize(bmp.bmWidth,bmp.bmHeight); } ------------------------------------ Trust in the code Luke. Yea right!

          L 1 Reply Last reply
          0
          • J John R Shaw

            First of all yes I know the answer, but if your are using Visual C++ and MFC, a simple search of the help sytem will give you the answer. Example: (You could write this) CSize GetSizeOfBitmap( CBitmap& MyBitmap ) { BITMAP bmp; MyBitmap.GetBitmap(&bmp); return CSize(bmp.bmWidth,bmp.bmHeight); } ------------------------------------ Trust in the code Luke. Yea right!

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            thanks sometimes look and see is not the same t!

            1 Reply Last reply
            0
            • L Lost User

              is there any way to get pixel size from HBITMAP? (i want to center it into rectangle) (most often it is loaded by LoadImage - maybe resource pixel size is available?) t!

              M Offline
              M Offline
              Module BJ
              wrote on last edited by
              #6

              Hello, How about this way? -------------------------------------- BITMAP bitmap = {0,}; GetObject(hBitmap, sizeof(BITMAP), &bitmap); -------------------------------------- I wish this way is helpful to you. Thanks.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups