OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [services/] [gfx/] [mw/] [v2_0/] [src/] [demos/] [mwin/] [mstretch.c] - Blame information for rev 174

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
/*
2
 * Copyright (c) 2001 Greg Haerr <greg@censoft.com>
3
 *
4
 * Demo program for StretchBlt
5
 */
6
#define MWINCLUDECOLORS
7
#include "windows.h"
8
#include "device.h"
9
 
10
extern MWIMAGEHDR image_penguin;
11
 
12
PMWIMAGEHDR image = &image_penguin;
13
 
14
#define APPCHILD        "test2"
15
 
16
/* forward decls*/
17
LRESULT CALLBACK ChildWndProc(HWND hwnd,UINT uMsg,WPARAM wp,LPARAM lp);
18
 
19
int
20
RegisterAppClass(void)
21
{
22
        WNDCLASS        wc;
23
 
24
        wc.style = CS_DBLCLKS | CS_VREDRAW | CS_HREDRAW;
25
        wc.lpfnWndProc = (WNDPROC)ChildWndProc;
26
        wc.cbClsExtra = 0;
27
        wc.cbWndExtra = 0;
28
        wc.hInstance = 0;
29
        wc.hIcon = 0; /*LoadIcon(GetHInstance(), MAKEINTRESOURCE( 1));*/
30
        wc.hCursor = 0; /*LoadCursor(NULL, IDC_ARROW);*/
31
        wc.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
32
        wc.lpszMenuName = NULL;
33
        wc.lpszClassName =  APPCHILD;
34
        return RegisterClass( &wc);
35
}
36
 
37
LRESULT CALLBACK
38
ChildWndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
39
{
40
        HDC             hdcMem;
41
        HBITMAP         hbmp, hbmpOrg;
42
        RECT            rc;
43
        PAINTSTRUCT     ps;
44
 
45
        switch(msg) {
46
        case WM_PAINT:
47
                BeginPaint(hwnd, &ps);
48
                GetClientRect(hwnd, &rc);
49
 
50
                /* redirect painting to offscreen dc*/
51
                hdcMem = CreateCompatibleDC(ps.hdc);
52
                hbmp = CreateCompatibleBitmap(hdcMem, image->width, image->height);
53
                hbmpOrg = SelectObject(hdcMem, hbmp);
54
 
55
                /* draw onto offscreen dc*/
56
                DrawDIB(hdcMem, 0, 0, image);
57
 
58
                /* stretch blit offscreen with physical screen*/
59
                StretchBlt(ps.hdc, 0, 0, rc.right, rc.bottom, hdcMem,
60
                        0, 0, image->width, image->height, MWROP_SRCCOPY);
61
                DeleteObject(SelectObject(hdcMem, hbmpOrg));
62
                DeleteDC(hdcMem);
63
                EndPaint(hwnd, &ps);
64
                break;
65
        default:
66
                return DefWindowProc( hwnd, msg, wp, lp);
67
        }
68
        return 0;
69
}
70
 
71
int WINAPI
72
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
73
        int nShowCmd)
74
{
75
        MSG     msg;
76
        RECT    rc;
77
 
78
        RegisterAppClass();
79
        GetWindowRect(GetDesktopWindow(), &rc);
80
 
81
        /* create penguin windows*/
82
        CreateWindowEx(0L, APPCHILD, "", WS_BORDER | WS_VISIBLE,
83
                10, 10, 50, 50,
84
                GetDesktopWindow(), (HMENU)1000, NULL, NULL);
85
 
86
        CreateWindowEx(0L, APPCHILD, "", WS_BORDER | WS_VISIBLE,
87
                10, 70, 200, 200,
88
                GetDesktopWindow(), (HMENU)1001, NULL, NULL);
89
 
90
        /* type ESC to quit...*/
91
        while( GetMessage(&msg, NULL, 0, 0)) {
92
                TranslateMessage(&msg);
93
                DispatchMessage(&msg);
94
        }
95
        return 0;
96
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.