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. Problem with mirrored bitmap

Problem with mirrored bitmap

Scheduled Pinned Locked Moved C / C++ / MFC
helpgraphicsquestion
4 Posts 2 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.
  • A Offline
    A Offline
    AnTri
    wrote on last edited by
    #1

    Hey, I use my printer dc to paint some text and graphic to my printer. I use MM_LOMETRIC as Mapmode because of the easy way of positioning. Now I have a big problem to print bitmaps. All bitmaps are mirrowed (around X-axis). I use the following code to paint the bitmap: .... CBitmap *pBitmap = new CBitmap(); HBITMAP hBitmap; hBitmap = (HBITMAP)::LoadImage(AfxGetInstanceHandle(),szPathToBitmap,IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION); pBitmap->Attach(hBitmap); ... CRect reRect; reRect.left = 10; reRect.right = 300; reRect.top = -100; reRect.bottom = -1000; CDC dcMem; BITMAP bm; pBitmap->GetBitmap(&bm); dcMem.CreateCompatibleDC(pDC); dcMem.SelectObject(pBitmap); pDC->BitBlt(reRect.left, reRect.top, bm.bmWidth, bm.bmHeight, &dcMem,0,0, SRCCOPY); What's wrong, and how could I fix it?

    M 1 Reply Last reply
    0
    • A AnTri

      Hey, I use my printer dc to paint some text and graphic to my printer. I use MM_LOMETRIC as Mapmode because of the easy way of positioning. Now I have a big problem to print bitmaps. All bitmaps are mirrowed (around X-axis). I use the following code to paint the bitmap: .... CBitmap *pBitmap = new CBitmap(); HBITMAP hBitmap; hBitmap = (HBITMAP)::LoadImage(AfxGetInstanceHandle(),szPathToBitmap,IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION); pBitmap->Attach(hBitmap); ... CRect reRect; reRect.left = 10; reRect.right = 300; reRect.top = -100; reRect.bottom = -1000; CDC dcMem; BITMAP bm; pBitmap->GetBitmap(&bm); dcMem.CreateCompatibleDC(pDC); dcMem.SelectObject(pBitmap); pDC->BitBlt(reRect.left, reRect.top, bm.bmWidth, bm.bmHeight, &dcMem,0,0, SRCCOPY); What's wrong, and how could I fix it?

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

      Maybe try

      //pDC->BitBlt(reRect.left, reRect.top, bm.bmWidth, bm.bmHeight, &dcMem,0,0, SRCCOPY);
      // Mirror the blt around the X axis...
      pDC->StretchBlt(reRect.left, reRect.top, bm.bmWidth, -bm.bmHeight, &dcMem, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);

      Mark

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

      A 1 Reply Last reply
      0
      • M Mark Salsbery

        Maybe try

        //pDC->BitBlt(reRect.left, reRect.top, bm.bmWidth, bm.bmHeight, &dcMem,0,0, SRCCOPY);
        // Mirror the blt around the X axis...
        pDC->StretchBlt(reRect.left, reRect.top, bm.bmWidth, -bm.bmHeight, &dcMem, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);

        Mark

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

        A Offline
        A Offline
        AnTri
        wrote on last edited by
        #3

        Thanks, this works fine for me (only the position is shifted), but why is the bitmap mirrored?

        M 1 Reply Last reply
        0
        • A AnTri

          Thanks, this works fine for me (only the position is shifted), but why is the bitmap mirrored?

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

          AnTri wrote:

          but why is the bitmap mirrored?

          The Y-axis is flipped by MM_LOMETRIC and BitBlt() renders scanlines in the positive direction from the starting point. 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