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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to display .jp2 and .jpg images in my dialog box?

How to display .jp2 and .jpg images in my dialog box?

Scheduled Pinned Locked Moved C / C++ / MFC
c++questiongraphicstutorial
5 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.
  • K Offline
    K Offline
    kapardhi
    wrote on last edited by
    #1

    Hai! In my dialog box i am able to display bitmap images by inserting an picture control in my dialog box and using the following code in Visual C++ : HBITMAP hBitmap; hBitmap = (HBITMAP) LoadImage (NULL, "C:\\Documents and Setttings\\MyPC\\Desktop\\MyImage.bmp", IMAGE_BITMAP, SM_CXICON, SM_CYICON, LR_LOADFROMFILE); csMyImage.SetBitmap (hBitmap); But how can i display .jp2 and .jpg images in my dialog box Thanks!

    J S 2 Replies Last reply
    0
    • K kapardhi

      Hai! In my dialog box i am able to display bitmap images by inserting an picture control in my dialog box and using the following code in Visual C++ : HBITMAP hBitmap; hBitmap = (HBITMAP) LoadImage (NULL, "C:\\Documents and Setttings\\MyPC\\Desktop\\MyImage.bmp", IMAGE_BITMAP, SM_CXICON, SM_CYICON, LR_LOADFROMFILE); csMyImage.SetBitmap (hBitmap); But how can i display .jp2 and .jpg images in my dialog box Thanks!

      J Offline
      J Offline
      Jijo Raj
      wrote on last edited by
      #2

      Hello kapardhi, This article will be helpful - Displaying a JPG in your MFC Application[^]. You can use GDI+ as well. Regards, Jijo.

      _____________________________________________________ http://weseetips.com[^] Visual C++ tips and tricks. Updated daily.

      K 1 Reply Last reply
      0
      • K kapardhi

        Hai! In my dialog box i am able to display bitmap images by inserting an picture control in my dialog box and using the following code in Visual C++ : HBITMAP hBitmap; hBitmap = (HBITMAP) LoadImage (NULL, "C:\\Documents and Setttings\\MyPC\\Desktop\\MyImage.bmp", IMAGE_BITMAP, SM_CXICON, SM_CYICON, LR_LOADFROMFILE); csMyImage.SetBitmap (hBitmap); But how can i display .jp2 and .jpg images in my dialog box Thanks!

        S Offline
        S Offline
        ShiXiangYang
        wrote on last edited by
        #3

        You can use CImage class. #include "atlimage.h" CImage pImage; HRESULT hResult = pImage.Load(m_TempPath); if (FAILED(hResult)) { ..... } CSize m_ScrSize; m_SrcSize.cx=m_ImageSize.cx=pImage.GetWidth(); m_SrcSize.cy=m_ImageSize.cy=pImage.GetHeight(); CClientDC *pDC; pImage.StretchBlt(pDC->m_hDC,0,0,m_ImageSize.cx,m_ImageSize.cy,0,0,m_SrcSize.cx,m_SrcSize.cy,SRCCOPY); pImage.Destroy();

        K 1 Reply Last reply
        0
        • J Jijo Raj

          Hello kapardhi, This article will be helpful - Displaying a JPG in your MFC Application[^]. You can use GDI+ as well. Regards, Jijo.

          _____________________________________________________ http://weseetips.com[^] Visual C++ tips and tricks. Updated daily.

          K Offline
          K Offline
          kapardhi
          wrote on last edited by
          #4

          Thankyou ! Assuming that both .jpg and.jp2 file are present in : C:\Documents and Settings\MyFolder Now can you please code me how to display the images , Itried but not successful! Thanks!

          1 Reply Last reply
          0
          • S ShiXiangYang

            You can use CImage class. #include "atlimage.h" CImage pImage; HRESULT hResult = pImage.Load(m_TempPath); if (FAILED(hResult)) { ..... } CSize m_ScrSize; m_SrcSize.cx=m_ImageSize.cx=pImage.GetWidth(); m_SrcSize.cy=m_ImageSize.cy=pImage.GetHeight(); CClientDC *pDC; pImage.StretchBlt(pDC->m_hDC,0,0,m_ImageSize.cx,m_ImageSize.cy,0,0,m_SrcSize.cx,m_SrcSize.cy,SRCCOPY); pImage.Destroy();

            K Offline
            K Offline
            kapardhi
            wrote on last edited by
            #5

            I am getting the following error message Run-Time Check Failure #3 - The variable 'pDC' is being used without being defined. 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