@@ -4250,8 +4250,8 @@ long CMiniWindow::TranslateImage(LPCTSTR ImageId, float Left, float Top, short M
4250
4250
4251
4251
XFORM xform;
4252
4252
xform.eM11 = Mxx;
4253
- xform.eM12 = Mxy;
4254
- xform.eM21 = Myx;
4253
+ xform.eM21 = Mxy;
4254
+ xform.eM12 = Myx;
4255
4255
xform.eM22 = Myy;
4256
4256
xform.eDx = Left;
4257
4257
xform.eDy = Top;
@@ -4262,6 +4262,10 @@ long CMiniWindow::TranslateImage(LPCTSTR ImageId, float Left, float Top, short M
4262
4262
return eBadParameter;
4263
4263
}
4264
4264
4265
+ // gives smoother rotations, especially with transparency
4266
+ dc.SetStretchBltMode (HALFTONE);
4267
+ SetBrushOrgEx (dc.m_hDC , 0 , 0 , NULL ); // as recommended after SetStretchBltMode
4268
+
4265
4269
switch (Mode)
4266
4270
{
4267
4271
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
4277
4281
// Create a memory dc for the mask
4278
4282
dcTrans.CreateCompatibleDC (&dc);
4279
4283
4280
- // Create the mask bitmap for the subset of the main image
4284
+ // Create the mask bitmap
4281
4285
CBitmap bitmapTrans;
4282
- bitmapTrans.CreateBitmap (iWidth, iHeight , 1 , 1 , NULL );
4286
+ bitmapTrans.CreateBitmap (m_iWidth, m_iHeight , 1 , 1 , NULL );
4283
4287
4284
4288
// Select the mask bitmap into the appropriate dc
4285
4289
CBitmap* pOldBitmapTrans = dcTrans.SelectObject (&bitmapTrans);
4286
4290
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
4288
4292
COLORREF crOldBackground = bmDC.SetBkColor (::GetPixel (bmDC, 0 , 0 ));
4289
4293
4290
4294
// Build mask based on transparent colour at location 0, 0
4291
4295
dcTrans.BitBlt (0 , 0 , iWidth, iHeight, &bmDC, 0 , 0 , SRCCOPY);
4292
4296
4293
4297
// 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);
4297
4301
4298
4302
// Restore settings
4299
4303
dcTrans.SelectObject (pOldBitmapTrans);
@@ -4303,7 +4307,10 @@ long CMiniWindow::TranslateImage(LPCTSTR ImageId, float Left, float Top, short M
4303
4307
}
4304
4308
break ;
4305
4309
4306
- default : return eBadParameter;
4310
+ default :
4311
+ bmDC.SelectObject (pOldbmp);
4312
+ return eBadParameter;
4313
+
4307
4314
} // end of switch
4308
4315
4309
4316
bmDC.SelectObject (pOldbmp);
0 commit comments