Click here to Skip to main content
11,719,903 members (79,874 online)
Click here to Skip to main content

High Speed Graphics Library for WinCE

, 24 Jun 2002 CPOL 229.2K 1.9K 90
Rate this:
Please Sign up or sign in to vote.
CEDraw is a high speed graphics library for WinCE.

Introduction

CEDraw is high speed graphics library in WinCE. It depends on GAPI . This code was written in C++ using embedded VC++ to compile it. Testing was done on an iPaq h3600 with WinCE 3.0. CEDraw use double buffer and direct write video buffer technology to enhance Draw speed. With its own graphics arithmetic the drawing speed is much faster than WinGDI.

CE Draw supports these functions:

  • Draw Pixel
  • Fill Screen
  • Draw Line,HLine,VLine
  • Draw Polyline
  • Draw Polygon
  • Draw Rectangle
  • Fill Rectangle ( with alpha blend support )
  • Fill Polygon
  • Draw Bitmap ( Support Bmp,Gif,Jpg format, Support alpha blend )
  • Draw Text ( Own font file, support Chinese, support gdi text )

How to use it

Before use the CEDraw Library, you must copy some support file in you system.

a. Copy the dll to you WinCE system directory

  1. If using in emulation mode, copy two of the dll in …\CEGraph\DLL\X86Em directory ( gx.dll & cegl.dll) to the emulation windows system directory, always in the D:\Windows CE Tools\wce300\MS Pocket PC\emulation\palm300\windows directoty, then copy the file Hzk16 in the …\CEGraph\Res directory to the WinCE Root directory, always in D:\Windows CE Tools\wce300\MS Pocket PC\emulation\palm300
  2. if using an Arm system, copy the two DLLs in …\CEGraph\DLL\Arm ( gx.dll & cegl.dll) to the Pocket PC windows system directory. Then copy the file HZK16 to the System Root directory.

There a 4 step to use it:

Step 1 Directory:

Set the including directory to …\CEGraph\Include
And lib directory to …\CEGraph\Lib\X86Em ( if using in emulation system) or …\CEGraph\Lib\Arm ( if using in pocketpc)

Open the project setting->Link->Object/library Modules 

Add CEGL.lib

Setp 2 Head file Including:

Include the cedraw graphics header file: CEGL.h

#include "stdafx.h"
#include "SDKSample.h"
#include <commctrl.h>

#include <cegl.h> // Include CE Graphics library

Step 3 Create the CE Draw Class:

// Create the CE Draw Object:
CCEDraw m_ceDraw;

// Initialize after CreateWindow()

BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)

{
    HWND hWnd;
    TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
    TCHAR szWindowClass[MAX_LOADSTRING]; // The window class name

    hInst = hInstance; // Store instance handle in our global variable
    // Initialize global strings
    LoadString(hInstance, IDC_SDKSAMPLE, szWindowClass, MAX_LOADSTRING);
    MyRegisterClass(hInstance, szWindowClass);
    LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
    hWnd = CreateWindow(szWindowClass, szTitle, WS_VISIBLE,
        0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), 
        NULL, NULL, hInstance, NULL);
    if (!hWnd)
    {
        return FALSE;
    }

    // Create the CE Grahpics Library
    m_ceDraw.Create( hWnd );

    ShowWindow(hWnd, nCmdShow);
    UpdateWindow(hWnd);

    return TRUE;
}

Step 4: Using CE Draw freely

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, 
                         WPARAM wParam, LPARAM lParam)
{
    HDC hdc;
    int wmId, wmEvent;
    PAINTSTRUCT ps;
    TCHAR szHello[MAX_LOADSTRING];

    switch (message)
    {
    case WM_PAINT:
        RECT rt;
        hdc = BeginPaint(hWnd, &ps);
        GetClientRect(hWnd, &rt);
        LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
        DrawText(hdc, szHello, _tcslen(szHello), &rt,
            DT_SINGLELINE | DT_VCENTER | DT_CENTER);
        EndPaint(hWnd, &ps);

        Render(); // Render screen
        break;

        ...
    }
}

void Render( void )
{
    POINT pt[5] ={ { 140, 100 }, { 70,120 }, { 104, 150 }, 
                   { 210, 122 }, { 75, 200 } };

    // Create the ce pen object...
    CCEPen cePen;
    // Convert RGB color to CE support Color
    cePen.CreatePen( 1, 1, m_ceDraw.ConvertColor( 255, 0, 0 ) ); 

    // Select it to the graphics system
    m_ceDraw.SetGDIObject( &cePen );

    // Create the ce brush object...
    CCEBrush ceBrush1, ceBrush2;
    ceBrush1.CreateBrush( 1, m_ceDraw.ConvertColor( 200, 200, 100 ), 1 );
    ceBrush2.CreateBrush( 1, m_ceDraw.ConvertColor( 0, 240, 0 ), 1 );

    // Select it to the graphics system
    m_ceDraw.SetGDIObject( &ceBrush1 );

    // Begin Draw
    m_ceDraw.BeginDraw();
    m_ceDraw.Clear( (DWORD)255 ); // Clear screen use white color

    m_ceDraw.DrawLine( 1, 1, 100, 100 ); // Draw line

    m_ceDraw.DrawRect( 10, 10, 110, 80 ); // Draw Rect

    m_ceDraw.FillRect( 30, 30, 50, 50 ); // Fill Rect

    m_ceDraw.SetGDIObject( &ceBrush2 ); // Select another color brush
    m_ceDraw.FillRect( 40, 40, 100, 100, 0.4 ); // fill Rect with alpha blend

    m_ceDraw.FillPolygon( pt, 5 ); // Draw an polygon
    m_ceDraw.SetGDIObject( &ceBrush1 ); // Select another color brush
    m_ceDraw.FillPolygon( pt, 5, 40, 40 ); // Draw an polygon

    CCEBitmap ceBmp1,ceBmp2;

    // Load Gif picture from file
    ceBmp1.LoadBitmap( &m_ceDraw, L"windows\\wcelogo1.gif" );      
    ceBmp2.LoadBitmap( &m_ceDraw, L"windows\\welcomehead.gif" );

    // Draw bitmap with alpha blend
    ceBmp2.BitBlt( &m_ceDraw, 1, 80, 0, 0, 0, 0, SRCALPHA, 0.6f ); 
    ceBmp1.BitBlt( &m_ceDraw, 1, 200, 0, 0, 0, 0, SRCALPHA, 0.6f );

    POINT ptText = { 1, 300 };
    // Draw text with pen color
    m_ceDraw.DrawText( &ptText, "Hello CE Graph!", 16, 1 ); 

    // End Draw
    m_ceDraw.EndDraw();
    m_ceDraw.Flip(); // Flip the back buffer to the video buffer
}

Step 5:

Don’t forgot to release it:

case WM_DESTROY:
        m_ceDraw.Release();
        PostQuitMessage(0);
        break;

Tips:

This graphics library cannot be directly used in an MFC appwizard generated frame. Because it has two windows, one is frame window, the other is child Window. I’ve write a Framework that supports MFC. If anyone who want to use it in MFC  email me.

  • The CEGLDLLPrj is the dll project of CE Graphics Library. It's high recommend that if you want to use this library, use the project to build your own DLL & Lib Files. To Build this project. You Can setting the include directory and lib directory with ...\CEGraph\include & lib (The same as  Step 1 Directory )
  • The SDKSample Project is the sample NOT using MFC. Build it after setting & copying the library& DLL Files.


Comments

Please report any bugs or feedback to jiet@msn.com

Thanks

This Code using GAPI Enum. Thanks to the Writer.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Jie Tang
Web Developer
China China
8 Years Development experience from MS-DOS v3.0 to WindowsXP in C/C++. Profession in Visual C++, Native Win32 and MFC programming, Embedded development.Computer Graphics(Computer Games),Network Program.

Living in China now.

You may also be interested in...

Comments and Discussions

 
GeneralMy vote of 1 Pin
__PPS__27-Oct-09 15:55
member__PPS__27-Oct-09 15:55 
Generallinking error for wince4.0 Pin
saurabhgoyal262-Sep-08 22:59
membersaurabhgoyal262-Sep-08 22:59 
Generalcannot draw pics and text Pin
menschMarkus1-Nov-07 0:21
membermenschMarkus1-Nov-07 0:21 
GeneralLinking errors Pin
Priya_Sundar13-Aug-07 19:55
memberPriya_Sundar13-Aug-07 19:55 
QuestionWhat about Ellipse? Pin
Jeffrey T17-Apr-07 10:07
memberJeffrey T17-Apr-07 10:07 
QuestionHow can I compile it using VS 2005? Pin
mAlleXXX24-Sep-06 5:51
membermAlleXXX24-Sep-06 5:51 
AnswerRe: How can I compile it using VS 2005? Pin
dzolee28-Sep-06 1:49
memberdzolee28-Sep-06 1:49 
QuestionHow can i change the font size? Pin
cyberjd14-Jun-06 9:52
membercyberjd14-Jun-06 9:52 
GeneralWindowsCE 5.0 Pin
Devil Hill12-Feb-06 16:45
memberDevil Hill12-Feb-06 16:45 
GeneralRe: WindowsCE 5.0 Pin
BloodRain20-Apr-06 9:12
memberBloodRain20-Apr-06 9:12 
QuestionHow do I Convert a JPG file to a BMP file using VC++? Pin
Kirubanandam12-Jan-06 20:15
memberKirubanandam12-Jan-06 20:15 
GeneralFor ppc 2003 Pin
edcedcedcedc17-Jun-05 5:06
memberedcedcedcedc17-Jun-05 5:06 
QuestionDoes this work on current WinCE? Pin
Dan McCarty18-Feb-05 5:37
memberDan McCarty18-Feb-05 5:37 
GeneralCEDraw with multipule windows Pin
ccarr22-Nov-04 17:19
memberccarr22-Nov-04 17:19 
GeneralRe: CEDraw with multipule windows Pin
ccarr22-Nov-04 18:30
memberccarr22-Nov-04 18:30 
General*SOLUTION* CEDraw with multipule windows Pin
ccarr25-Nov-04 16:24
memberccarr25-Nov-04 16:24 
GeneralRe: *SOLUTION* CEDraw with multipule windows Pin
Ibrahim4554353-Jul-06 2:28
memberIbrahim4554353-Jul-06 2:28 
QuestionHow to use it in MFC based WinCE program ? Pin
jarell11-Oct-04 19:58
memberjarell11-Oct-04 19:58 
AnswerRe: How to use it in MFC based WinCE program ? Pin
zjm1976082912-Feb-06 15:21
memberzjm1976082912-Feb-06 15:21 
GeneralRe: How to use it in MFC based WinCE program ? Pin
xindeng30-Mar-07 16:16
memberxindeng30-Mar-07 16:16 
GeneralRe: How to use it in MFC based WinCE program ? Pin
wcqq12319-Dec-11 20:54
memberwcqq12319-Dec-11 20:54 
Generalrotation Pin
Anonymous11-Oct-04 8:00
sussAnonymous11-Oct-04 8:00 
GeneralCannot work on SH3 and TEXT problem Pin
marce0025-Oct-04 16:25
membermarce0025-Oct-04 16:25 
GeneralRe: Cannot work on SH3 and TEXT problem Pin
Anonymous22-Nov-04 23:25
sussAnonymous22-Nov-04 23:25 
GeneralUsing this in a DIALOG Pin
Alex Evans27-Sep-04 19:44
memberAlex Evans27-Sep-04 19:44 
GeneralProblems trying CEGL in a x86 Pin
Jordi Ros24-Aug-04 3:30
sussJordi Ros24-Aug-04 3:30 
GeneralRe: Problems trying CEGL in a x86 Pin
niceguyeddie7-Sep-04 11:25
memberniceguyeddie7-Sep-04 11:25 
GeneralCan't get it working on an x86 emulator Pin
niceguyeddie13-Aug-04 6:30
memberniceguyeddie13-Aug-04 6:30 
GeneralRe: Can't get it working on an x86 emulator Pin
niceguyeddie16-Aug-04 9:19
memberniceguyeddie16-Aug-04 9:19 
GeneralRe: Can't get it working on an x86 emulator Pin
freddy1ca21-Aug-04 23:24
memberfreddy1ca21-Aug-04 23:24 
GeneralRe: Can't get it working on an x86 emulator Pin
niceguyeddie23-Aug-04 3:47
memberniceguyeddie23-Aug-04 3:47 
GeneralHelp me &quot;Line Thick&quot; Pin
duydung2-Jul-04 9:31
memberduydung2-Jul-04 9:31 
GeneralHouston, we have a problem with the DrawText function (using LPCTSTR) Pin
thm18-Feb-04 5:04
memberthm18-Feb-04 5:04 
GeneralRe: Houston, we have a problem with the DrawText function (using LPCTSTR) Pin
Hoyt F.16-Jun-04 4:18
memberHoyt F.16-Jun-04 4:18 
GeneralDLLs arex not there Pin
shubhs12-Feb-04 17:22
membershubhs12-Feb-04 17:22 
GeneralDisplay map in Pocket PC Pin
senhtahi3-Dec-03 4:19
membersenhtahi3-Dec-03 4:19 
GeneralRe: Display map in Pocket PC Pin
SuperGuruHacker1-Jun-04 21:37
sussSuperGuruHacker1-Jun-04 21:37 
QuestionWhat about Windows CE 4.1 Pin
Alpha Barry17-Jul-03 10:27
memberAlpha Barry17-Jul-03 10:27 
AnswerRe: What about Windows CE 4.1 Pin
Jie Tang12-Sep-03 7:56
memberJie Tang12-Sep-03 7:56 
GeneralRe: What about Windows CE 4.1 Pin
codehar31-Aug-04 20:55
membercodehar31-Aug-04 20:55 
Generalwin ce 4.0 emulator Pin
magic83-Apr-03 15:14
membermagic83-Apr-03 15:14 
GeneralRe: win ce 4.0 emulator Pin
tjaaaa9-Jun-03 5:27
susstjaaaa9-Jun-03 5:27 
GeneralRe: win ce 4.0 emulator Pin
monitomonito14-Apr-04 12:27
membermonitomonito14-Apr-04 12:27 
GeneralRe: win ce 4.0 emulator Pin
freddy1ca21-Aug-04 23:20
memberfreddy1ca21-Aug-04 23:20 
GeneralMIPS Pin
emersonfernando18-Feb-03 2:27
memberemersonfernando18-Feb-03 2:27 
GeneralRe: MIPS Pin
Anonymous7-Jan-04 19:56
sussAnonymous7-Jan-04 19:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150901.1 | Last Updated 25 Jun 2002
Article Copyright 2002 by Jie Tang
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid