| | 172 | |
|---|
| | 173 | class DZoomedCachedBitmap : DCachedBitmap |
|---|
| | 174 | { |
|---|
| | 175 | public: |
|---|
| | 176 | this( DBitmap parent, int zoom ) |
|---|
| | 177 | { |
|---|
| | 178 | super(); |
|---|
| | 179 | HDC dtw = GetDC( GetDesktopWindow() ); |
|---|
| | 180 | GetObject( parent.hbm, bm.sizeof, &bm ); |
|---|
| | 181 | int w,h; |
|---|
| | 182 | getZoomParam( zoom, w, h ); |
|---|
| | 183 | HDC ppdc = CreateCompatibleDC( dtw ); |
|---|
| | 184 | bmdc = CreateCompatibleDC( dtw ); |
|---|
| | 185 | hbm = CreateCompatibleBitmap( bmdc, w, h ); |
|---|
| | 186 | HGDIOBJ obm = SelectObject( ppdc, parent.hbm ); |
|---|
| | 187 | SelectObject( bmdc, hbm ); |
|---|
| | 188 | // render self (parent) onto new bitmap and hdc |
|---|
| | 189 | SetStretchBltMode( bmdc, COLORONCOLOR ); |
|---|
| | 190 | StretchBlt( bmdc, 0, 0, w, h, |
|---|
| | 191 | ppdc, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY ); |
|---|
| | 192 | GetObject( hbm, bm.sizeof, &bm ); |
|---|
| | 193 | SelectObject( ppdc, obm ); |
|---|
| | 194 | DeleteDC( ppdc ); |
|---|
| | 195 | ReleaseDC( dtw, GetDesktopWindow() ); |
|---|
| | 196 | } |
|---|
| | 197 | } |
|---|
| | 198 | |
|---|
| | 199 | class DZoomedBitmap : DBitmap |
|---|
| | 200 | { |
|---|
| | 201 | public: |
|---|
| | 202 | |
|---|
| | 203 | this( DBitmap parent, int zoomx, int zoomy ) |
|---|
| | 204 | { |
|---|
| | 205 | super(); |
|---|
| | 206 | HDC bmdc; |
|---|
| | 207 | HDC dtw = GetDC( GetDesktopWindow() ); |
|---|
| | 208 | GetObject( parent.hbm, bm.sizeof, &bm ); |
|---|
| | 209 | int w = getZoomParam( zoomx, bm.bmWidth ); |
|---|
| | 210 | int h = getZoomParam( zoomy, bm.bmHeight ); |
|---|
| | 211 | HDC ppdc = CreateCompatibleDC( dtw ); |
|---|
| | 212 | bmdc = CreateCompatibleDC( dtw ); |
|---|
| | 213 | hbm = CreateCompatibleBitmap( dtw, w, h ); |
|---|
| | 214 | HGDIOBJ obm = SelectObject( ppdc, parent.hbm ); |
|---|
| | 215 | SelectObject( bmdc, hbm ); |
|---|
| | 216 | // render self (parent) onto new bitmap and hdc |
|---|
| | 217 | SetStretchBltMode( bmdc, COLORONCOLOR ); |
|---|
| | 218 | StretchBlt( bmdc, 0, 0, w, h, |
|---|
| | 219 | ppdc, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY ); |
|---|
| | 220 | GetObject( hbm, bm.sizeof, &bm ); |
|---|
| | 221 | |
|---|
| | 222 | SelectObject( ppdc, obm ); |
|---|
| | 223 | DeleteDC( ppdc ); |
|---|
| | 224 | DeleteDC( bmdc ); |
|---|
| | 225 | ReleaseDC( dtw, GetDesktopWindow() ); |
|---|
| | 226 | } |
|---|
| | 227 | this( DBitmap parent, int zoom ) |
|---|
| | 228 | { |
|---|
| | 229 | this( parent, zoom, zoom ); |
|---|
| | 230 | } |
|---|
| | 231 | |
|---|
| | 232 | int getZoomParam( int zoom, int v ) |
|---|
| | 233 | { |
|---|
| | 234 | return ( zoom == 0 ) |
|---|
| | 235 | ? 1 |
|---|
| | 236 | : ( ( zoom > 0 ) |
|---|
| | 237 | ? (v*zoom) |
|---|
| | 238 | : (v/(-zoom)) |
|---|
| | 239 | ); |
|---|
| | 240 | } |
|---|
| | 241 | |
|---|
| | 242 | } |
|---|