Skip to content

Commit 1540f4c

Browse files
committed
Enhancements to WindowTranslateImage
1 parent bfc9f2d commit 1540f4c

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

miniwindow.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4250,8 +4250,8 @@ long CMiniWindow::TranslateImage(LPCTSTR ImageId, float Left, float Top, short M
42504250

42514251
XFORM xform;
42524252
xform.eM11 = Mxx;
4253-
xform.eM12 = Mxy;
4254-
xform.eM21 = Myx;
4253+
xform.eM21 = Mxy;
4254+
xform.eM12 = Myx;
42554255
xform.eM22 = Myy;
42564256
xform.eDx = Left;
42574257
xform.eDy = Top;
@@ -4262,6 +4262,10 @@ long CMiniWindow::TranslateImage(LPCTSTR ImageId, float Left, float Top, short M
42624262
return eBadParameter;
42634263
}
42644264

4265+
// gives smoother rotations, especially with transparency
4266+
dc.SetStretchBltMode (HALFTONE);
4267+
SetBrushOrgEx(dc.m_hDC, 0, 0, NULL); // as recommended after SetStretchBltMode
4268+
42654269
switch (Mode)
42664270
{
42674271
case 1: dc.BitBlt (0, 0, iWidth, iHeight, &bmDC, 0, 0, SRCCOPY);
@@ -4277,23 +4281,23 @@ long CMiniWindow::TranslateImage(LPCTSTR ImageId, float Left, float Top, short M
42774281
// Create a memory dc for the mask
42784282
dcTrans.CreateCompatibleDC(&dc);
42794283

4280-
// Create the mask bitmap for the subset of the main image
4284+
// Create the mask bitmap
42814285
CBitmap bitmapTrans;
4282-
bitmapTrans.CreateBitmap(iWidth, iHeight, 1, 1, NULL);
4286+
bitmapTrans.CreateBitmap(m_iWidth, m_iHeight, 1, 1, NULL);
42834287

42844288
// Select the mask bitmap into the appropriate dc
42854289
CBitmap* pOldBitmapTrans = dcTrans.SelectObject(&bitmapTrans);
42864290

4287-
// Our transparent pixel will be at 0,0 (top left corner) of original image (not subimage)
4291+
// Our transparent pixel will be at 0,0 (top left corner) of original image
42884292
COLORREF crOldBackground = bmDC.SetBkColor (::GetPixel (bmDC, 0, 0));
42894293

42904294
// Build mask based on transparent colour at location 0, 0
42914295
dcTrans.BitBlt (0, 0, iWidth, iHeight, &bmDC, 0, 0, SRCCOPY);
42924296

42934297
// Do the work
4294-
dc.BitBlt (Left, Top, iWidth, iHeight, &bmDC, 0, 0, SRCINVERT);
4295-
dc.BitBlt (Left, Top, iWidth, iHeight, &dcTrans, 0, 0, SRCAND);
4296-
dc.BitBlt (Left, Top, iWidth, iHeight, &bmDC, 0, 0, SRCINVERT);
4298+
dc.BitBlt (0, 0, iWidth, iHeight, &bmDC, 0, 0, SRCINVERT);
4299+
dc.BitBlt (0, 0, iWidth, iHeight, &dcTrans, 0, 0, SRCAND);
4300+
dc.BitBlt (0, 0, iWidth, iHeight, &bmDC, 0, 0, SRCINVERT);
42974301

42984302
// Restore settings
42994303
dcTrans.SelectObject(pOldBitmapTrans);
@@ -4303,7 +4307,10 @@ long CMiniWindow::TranslateImage(LPCTSTR ImageId, float Left, float Top, short M
43034307
}
43044308
break;
43054309

4306-
default: return eBadParameter;
4310+
default:
4311+
bmDC.SelectObject(pOldbmp);
4312+
return eBadParameter;
4313+
43074314
} // end of switch
43084315

43094316
bmDC.SelectObject(pOldbmp);

0 commit comments

Comments
 (0)