Problem with mirrored bitmap
-
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? -
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?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:
-
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:
-
Thanks, this works fine for me (only the position is shifted), but why is the bitmap mirrored?
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: