Changeset 22

Show
Ignore:
Timestamp:
10/19/05 14:27:54 (3 years ago)
Author:
l8night
Message:

oops I left a few bits of debugging in.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/l8night/dfc/bitmap.d

    r15 r22  
    3838        GetObject( hbm, bm.sizeof, &bm ); 
    3939    } 
    40  
     40     
    4141    this( char[] name ) 
    4242    { 
     
    129129    } 
    130130 
    131     void renderStretchOnto( HDC dc, int x, int y, int w, int h, int sx, int sy, int sw, int sh ) 
    132     { 
    133         if ( prepareDC( dc ) ) { 
    134             StretchBlt( dc, x, y, w, h, bmdc, sx, sy, sw, sh, SRCCOPY ); 
    135         } 
    136     } 
    137131    void renderZoomOnto( HDC dc, int x, int y, int zoom ) 
    138132    { 
     
    161155    } 
    162156 
     157    void renderStretchOnto( HDC dc, int x, int y, int w, int h, int sx, int sy, int sw, int sh ) 
     158    { 
     159        if ( prepareDC( dc ) ) { 
     160            StretchBlt( dc, x, y, w, h, bmdc, sx, sy, sw, sh, SRCCOPY ); 
     161        } 
     162    } 
     163 
    163164    void renderScaledOnto( HDC dc, int x, int y, int w, int h ) 
    164165    { 
     
    169170    } 
    170171} 
     172 
     173class DZoomedCachedBitmap : DCachedBitmap 
     174{ 
     175public: 
     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 
     199class DZoomedBitmap : DBitmap 
     200{ 
     201public: 
     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} 
  • trunk/l8night/dfc/mswin.d

    r17 r22  
    581581    void create( DWORD style, DWORD styleEx, char[] windowName, int w, int h, NativeWindow parent ) 
    582582    { 
    583         printf( "debug DWND-000 (%x)\n", cast(int)(cast(void*)(parent)) ); 
    584         printf( "debug        p.hwnd=(%x)\n", cast(int)(cast(void*)(parent.hwnd)) ); 
    585583        doCreateWindow( style, windowName,  styleEx, 
    586584                            CW_USEDEFAULT, CW_USEDEFAULT, w, h, 
    587585                            parent.hwnd,    cast(HMENU)null); 
    588         printf( "debug DWND-000\n" ); 
    589586    } 
    590587    void create( DWORD style, DWORD styleEx, char[] windowName, SIZE * size, NativeWindow parent )