@@ -2934,52 +2934,17 @@ static bool AlphaBlt(wxMSWDCImpl* dcDst,
2934
2934
const wxBitmap& bmpDst = dcDst->GetSelectedBitmap ();
2935
2935
if ( bmpDst.IsOk () && !bmpDst.HasAlpha () && bmpDst.GetDepth () == 32 )
2936
2936
{
2937
- // We need to deselect the bitmap from the memory DC it is
2938
- // currently selected into before modifying it.
2939
- wxBitmap bmpOld = bmpDst;
2940
- dcDst->DoSelect (wxNullBitmap);
2937
+ wxBitmap bmp (dstWidth, dstHeight, 32 );
2938
+ wxMemoryDC dc (bmp);
2941
2939
2942
- // Notice the extra block: we must destroy wxAlphaPixelData
2943
- // before selecting the bitmap into the DC again.
2944
- {
2945
- // Since drawn bitmap can only partially overlap
2946
- // with destination bitmap we need to calculate
2947
- // efective drawing area location.
2948
- const wxRect rectDst (bmpOld.GetSize ());
2949
- const wxRect rectDrawn (x, y, dstWidth, dstHeight);
2950
- const wxRect r = rectDrawn.Intersect (rectDst);
2951
-
2952
- wxAlphaPixelData data (bmpOld);
2953
- if ( data )
2954
- {
2955
- wxAlphaPixelData::Iterator p (data);
2956
-
2957
- p.Offset (data, r.GetLeft (), r.GetTop ());
2958
- for ( int old_y = 0 ; old_y < r.GetHeight (); old_y++ )
2959
- {
2960
- wxAlphaPixelData::Iterator rowStart = p;
2961
- for ( int old_x = 0 ; old_x < r.GetWidth (); old_x++ )
2962
- {
2963
- // We choose to use wxALPHA_TRANSPARENT instead
2964
- // of perhaps more logical wxALPHA_OPAQUE here
2965
- // to ensure that the bitmap remains the same
2966
- // as before, i.e. without any alpha at all.
2967
- p.Alpha () = wxALPHA_TRANSPARENT;
2968
- ++p;
2969
- }
2970
-
2971
- p = rowStart;
2972
- p.OffsetY (data, 1 );
2973
- }
2974
- }
2975
- }
2976
-
2977
- // Using wxAlphaPixelData sets the internal "has alpha" flag
2978
- // which is usually what we need, but in this particular case
2979
- // we use it to get rid of alpha, not set it, so reset it back.
2980
- bmpOld.ResetAlpha ();
2981
-
2982
- dcDst->DoSelect (bmpOld);
2940
+ // Fetch the content of the destination area into the temporary buffer.
2941
+ wxRect r (x, y, dstWidth, dstHeight);
2942
+ if (bmpDst.GetWidth () < x + dstWidth || bmpDst.GetHeight () < y + dstHeight)
2943
+ return true ;
2944
+ dc.DrawBitmap (dcDst->DoGetAsBitmap (&r), 0 , 0 );
2945
+ // Drawing the source over the temporary buffer.
2946
+ dcDst->DoBlit (x, y, dstWidth, dstHeight, &dc, 0 , 0 );
2947
+ return true ;
2983
2948
}
2984
2949
#endif // wxHAS_RAW_BITMAP
2985
2950
0 commit comments