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. Load Bitmap from a specified path

Load Bitmap from a specified path

Scheduled Pinned Locked Moved C / C++ / MFC
graphicshelp
4 Posts 3 Posters 0 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.
  • S Offline
    S Offline
    S DARWIN PAUL RAJ
    wrote on last edited by
    #1

    Hai, HBITMAP bmp1; bmp1=SHLoadDIBitmap(_T("D:\\Code Guru\\a.bmp")); While I am debugging bmp1= not used, sometimes garbage value: how shall I find the width and height of the bmp1. BITMAP bminfo; bmp1.GetBitmap(&bminfo); When I use the above, It shows an error. left of '.GetBitmap' must have class/struct/union type Is there any other function instead of GetBitmap. pDC->StretchBlt(0,0,rc.Width(),rc.Height(), &dcMem, 0, 0, bminfo.bmWidth, bminfo.bmHeight, SRCCOPY); Note: compatible for WinCE DARWIN PAUL RAJ

    T D 2 Replies Last reply
    0
    • S S DARWIN PAUL RAJ

      Hai, HBITMAP bmp1; bmp1=SHLoadDIBitmap(_T("D:\\Code Guru\\a.bmp")); While I am debugging bmp1= not used, sometimes garbage value: how shall I find the width and height of the bmp1. BITMAP bminfo; bmp1.GetBitmap(&bminfo); When I use the above, It shows an error. left of '.GetBitmap' must have class/struct/union type Is there any other function instead of GetBitmap. pDC->StretchBlt(0,0,rc.Width(),rc.Height(), &dcMem, 0, 0, bminfo.bmWidth, bminfo.bmHeight, SRCCOPY); Note: compatible for WinCE DARWIN PAUL RAJ

      T Offline
      T Offline
      ThatsAlok
      wrote on last edited by
      #2

      S.DARWIN PAUL RAJ wrote: HBITMAP bmp1; bmp1=SHLoadDIBitmap(_T("D:\\Code Guru\\a.bmp")); While I am debugging bmp1= not used, sometimes garbage value: and S.DARWIN PAUL RAJ wrote: BITMAP bminfo; bmp1.GetBitmap(&bminfo); Buddy bmp1 is amember of HANDLE,and HANDLE is neither CLASS,STRUCT or UNION ----------------------------- "I Think It will Work" ----------------------------- Alok Gupta visit me at http://www.thisisalok.tk

      1 Reply Last reply
      0
      • S S DARWIN PAUL RAJ

        Hai, HBITMAP bmp1; bmp1=SHLoadDIBitmap(_T("D:\\Code Guru\\a.bmp")); While I am debugging bmp1= not used, sometimes garbage value: how shall I find the width and height of the bmp1. BITMAP bminfo; bmp1.GetBitmap(&bminfo); When I use the above, It shows an error. left of '.GetBitmap' must have class/struct/union type Is there any other function instead of GetBitmap. pDC->StretchBlt(0,0,rc.Width(),rc.Height(), &dcMem, 0, 0, bminfo.bmWidth, bminfo.bmHeight, SRCCOPY); Note: compatible for WinCE DARWIN PAUL RAJ

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        Try:

        HBITMAP hBitmap = SHLoadDIBitmap(_T("D:\\Code Guru\\a.bmp"));
        if (NULL != hBitmap)
        {
        CBitmap *pBitmap = CBitmap::FromHandle(hBitmap);

        BITMAP bmInfo;
        if (pBitmap->GetBitmap(&bmInfo) != 0)
        {
            ...
        }
        

        }


        "When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen

        S 1 Reply Last reply
        0
        • D David Crow

          Try:

          HBITMAP hBitmap = SHLoadDIBitmap(_T("D:\\Code Guru\\a.bmp"));
          if (NULL != hBitmap)
          {
          CBitmap *pBitmap = CBitmap::FromHandle(hBitmap);

          BITMAP bmInfo;
          if (pBitmap->GetBitmap(&bmInfo) != 0)
          {
              ...
          }
          

          }


          "When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen

          S Offline
          S Offline
          S DARWIN PAUL RAJ
          wrote on last edited by
          #4

          Thank you, I got the result CBitmap bmp; HBITMAP bmp1; bmp1 =SHLoadDIBitmap(_T("D:\\codeproject\\a.bmp")); bmp.Attach(bmp1); BITMAP bminfo; bmp.GetBitmap(&bminfo); CDC dcMem; HBITMAP hbmpOld; dcMem.CreateCompatibleDC(pDC); hbmpOld =(HBITMAP)dcMem.SelectObject(&bmp); pDC->StretchBlt(0,0,rc.Width(),rc.Height(),&dcMem, 0,0, bminfo.bmWidth, bminfo.bmHeight, SRCCOPY); dcMem.SelectObject(hbmpOld); Still one more problem, When I stretched this bitmap into the entire screen, the controls(Button) which I placed above the bitmap not moved with bitmap, I want that todo, Give your hand on this issue regards DARWIN PAUL RAJ

          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