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. How to display a JPG file using BitBlt?

How to display a JPG file using BitBlt?

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
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.
  • T Offline
    T Offline
    TooShy2Talk
    wrote on last edited by
    #1

    Hi again, I need to display a JPG file from a location - ex. c:\img.jpg using BitBlt but i don't know how to implement. This will be under OnDraw() or OnPaint() function. I read that this will use CDC but i don't know how to relate. If you knew of a thread please inform me. Hope you can help me. Thanks.

    M F 2 Replies Last reply
    0
    • T TooShy2Talk

      Hi again, I need to display a JPG file from a location - ex. c:\img.jpg using BitBlt but i don't know how to implement. This will be under OnDraw() or OnPaint() function. I read that this will use CDC but i don't know how to relate. If you knew of a thread please inform me. Hope you can help me. Thanks.

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      Example:

      void CMyWnd::OnPaint()
      {
          CPaintDC dc(this); // device context for painting

      CImage JPEGImage;
          JPEGImage.Load(_T("c:\\img.jpg"));
          JPEGImage.BitBlt(dc, 0, 0, SRCCOPY);
      }

      Mark

      Mark Salsbery Microsoft MVP - Visual C++ :java:

      T 1 Reply Last reply
      0
      • T TooShy2Talk

        Hi again, I need to display a JPG file from a location - ex. c:\img.jpg using BitBlt but i don't know how to implement. This will be under OnDraw() or OnPaint() function. I read that this will use CDC but i don't know how to relate. If you knew of a thread please inform me. Hope you can help me. Thanks.

        F Offline
        F Offline
        followait
        wrote on last edited by
        #3

        Select an HBITMAP object into a memory dc first. An easy way to get an HBITMAP from a JPG file is using GDI+. You might find it in google. gl

        1 Reply Last reply
        0
        • M Mark Salsbery

          Example:

          void CMyWnd::OnPaint()
          {
              CPaintDC dc(this); // device context for painting

          CImage JPEGImage;
              JPEGImage.Load(_T("c:\\img.jpg"));
              JPEGImage.BitBlt(dc, 0, 0, SRCCOPY);
          }

          Mark

          Mark Salsbery Microsoft MVP - Visual C++ :java:

          T Offline
          T Offline
          TooShy2Talk
          wrote on last edited by
          #4

          Is JPEGImage a derived class? To create? or already exist.

          M 1 Reply Last reply
          0
          • T TooShy2Talk

            Is JPEGImage a derived class? To create? or already exist.

            M Offline
            M Offline
            Mark Salsbery
            wrote on last edited by
            #5

            TooShy2Talk wrote:

            Is JPEGImage a derived class?

            No just a quickly chosen variable name.  The class is CImage... I forgot:

            #include <atlimage.h> // CImage class

            If you're using VC 6, upgrade! then I'll show a sample the long way.  The CImage class makes it easy :) Mark

            Mark Salsbery Microsoft MVP - Visual C++ :java:

            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