83 {
84 assert(bitmap.GetWidth() == mid + (bitmap.GetWidth() - mid) / 2 + (bitmap.GetWidth() - mid) / 2);
85 assert(bitmap.GetHeight() == mid + (bitmap.GetHeight() - mid) / 2 + (bitmap.GetHeight() - mid) / 2);
86 assert(r.width >= bitmap.GetWidth() - mid);
87 assert(r.height >= bitmap.GetHeight() - mid);
88 wxMemoryDC memDC;
89 memDC.SelectObject(bitmap);
90
91
92
93 const auto uw0 = (bitmap.GetWidth() - mid) / 2;
94 const auto uw1 = mid;
95 const auto uw2 = bitmap.GetWidth() - uw0 - uw1;
96
97 const auto vh0 = (bitmap.GetHeight() - mid) / 2;
98 const auto vh1 = mid;
99 const auto vh2 = bitmap.GetHeight() - vh1 - vh0;
100
101 const auto u0 = 0;
102 const auto u1 = uw0;
103 const auto u2 = uw0 + uw1;
104
105 const auto v0 = 0;
106 const auto v1 = vh0;
107 const auto v2 = vh0 + vh1;
108
109
110
111 const auto xw0 =
std::min(uw0, r.width / 2);
112 const auto xw2 =
std::min(uw2, r.width / 2);
113 const auto xw1 = std::max(r.width - xw0 - xw2, 0);
114
115 const auto yh0 =
std::min(vh0, r.height / 2);
116 const auto yh2 =
std::min(vh2, r.height / 2);
117 const auto yh1 = std::max(r.height - yh0 - yh2, 0);
118
119 const auto x0 = r.x;
120 const auto x1 = r.x + xw0;
121 const auto x2 = r.x + xw0 + xw1;
122
123 const auto y0 = r.y;
124 const auto y1 = r.y + yh0;
125 const auto y2 = r.y + yh0 + yh1;
126
127
128 dc.StretchBlit(x0, y0, xw0, yh0, &memDC, u0, v0, uw0, vh0, wxCOPY, true);
129 dc.StretchBlit(x2, y0, xw2, yh0, &memDC, u2, v0, uw2, vh0, wxCOPY, true);
130 dc.StretchBlit(x0, y2, xw0, yh2, &memDC, u0, v2, uw0, vh2, wxCOPY, true);
131 dc.StretchBlit(x2, y2, xw2, yh2, &memDC, u2, v2, uw2, vh2, wxCOPY, true);
132
133 if(xw1 > 0 && yh1 > 0)
134 {
135 dc.StretchBlit(x1, y0, xw1, yh0, &memDC, u1, v0, uw1, vh0, wxCOPY, true);
136
137 dc.StretchBlit(x0, y1, xw0, yh1, &memDC, u0, v1, uw0, vh1, wxCOPY, true);
138 dc.StretchBlit(x1, y1, xw1, yh1, &memDC, u1, v1, uw1, vh1, wxCOPY, true);
139 dc.StretchBlit(x2, y1, xw2, yh1, &memDC, u2, v1, uw2, vh1, wxCOPY, true);
140
141 dc.StretchBlit(x1, y2, xw1, yh2, &memDC, u1, v2, uw1, vh2, wxCOPY, true);
142 }
143 }