Click here to Skip to main content
6,630,586 members and growing! (17,830 online)
Email Password   helpLost your password?
Platforms, Frameworks & Libraries » Mobile Development » Graphics and Multimedia     Intermediate

High Speed Graphics Library for WinCE

By Jie Tang

CEDraw is high speed graphics library in WinCE
C++, eVC 3.0, Windows, Mobile, Visual Studio, MFC, Dev
Posted:24 Jun 2002
Views:179,250
Bookmarked:71 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
19 votes for this article.
Popularity: 5.55 Rating: 4.34 out of 5
2 votes, 14.3%
1

2

3
3 votes, 21.4%
4
9 votes, 64.3%
5

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Jie Tang


Member
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.
Occupation: Web Developer
Location: China China

Other popular Mobile Development articles:

  • Writing Your Own GPS Applications: Part 2
    In part two of the series, the author of "GPS.NET" teaches developers how to write GPS applications suitable for the real world by mastering GPS precision concepts. Source code includes a working NMEA interpreter and sample high-precision application in C# and VB.NET.
  • Writing Your Own GPS Applications: Part I
    What is it that GPS applications need to be good enough to use for in-car navigation? Also, how does the process of interpreting GPS data actually work? In this three-part series, I will cover both topics and give you the skills you need to write a commercial-grade GPS application.
  • Learn How to Find GPS Location on Any SmartPhone, and Then Make it Relevant
    A step by step tutorial for getting GPS from any SmartPhone, even without GPS built in, and then making location useful.
  • iPhone UI in Windows Mobile
    It's an interface that works with transparency effects. As a sample I used an interface just like the iPhone one. In this tutorial I am explaining how simple is working with transparency on Windows Mobile.
  • Pocket 1945 - A C# .NET CF Shooter
    An article on Pocket PC game development
Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 25 of 45 (Total in Forum: 45) (Refresh)FirstPrevNext
GeneralMy vote of 1 Pinmember__PPS__16:55 27 Oct '09  
Generallinking error for wince4.0 Pinmembersaurabhgoyal2623:59 2 Sep '08  
Generalcannot draw pics and text PinmembermenschMarkus1:21 1 Nov '07  
GeneralLinking errors PinmemberPriya_Sundar20:55 13 Aug '07  
GeneralWhat about Ellipse? PinmemberJeffrey T11:07 17 Apr '07  
GeneralHow can I compile it using VS 2005? PinmembermAlleXXX6:51 24 Sep '06  
GeneralRe: How can I compile it using VS 2005? Pinmemberdzolee2:49 28 Sep '06  
GeneralHow can i change the font size? Pinmembercyberjd10:52 14 Jun '06  
GeneralWindowsCE 5.0 PinmemberDevil Hill17:45 12 Feb '06  
GeneralRe: WindowsCE 5.0 PinmemberBloodRain10:12 20 Apr '06  
QuestionHow do I Convert a JPG file to a BMP file using VC++? PinmemberKirubanandam21:15 12 Jan '06  
GeneralFor ppc 2003 Pinmemberedcedcedcedc6:06 17 Jun '05  
GeneralDoes this work on current WinCE? PinmemberDan McCarty6:37 18 Feb '05  
GeneralCEDraw with multipule windows Pinmemberccarr18:19 22 Nov '04  
GeneralRe: CEDraw with multipule windows Pinmemberccarr19:30 22 Nov '04  
General*SOLUTION* CEDraw with multipule windows Pinmemberccarr17:24 25 Nov '04  
GeneralRe: *SOLUTION* CEDraw with multipule windows PinmemberIbrahim4554353:28 3 Jul '06  
GeneralHow to use it in MFC based WinCE program ? Pinmemberjarell20:58 11 Oct '04  
GeneralRe: How to use it in MFC based WinCE program ? Pinmemberzjm1976082916:21 12 Feb '06  
GeneralRe: How to use it in MFC based WinCE program ? Pinmemberxindeng17:16 30 Mar '07  
Generalrotation PinsussAnonymous9:00 11 Oct '04  
GeneralCannot work on SH3 and TEXT problem Pinmembermarce00217:25 5 Oct '04  
GeneralRe: Cannot work on SH3 and TEXT problem PinsussAnonymous0:25 23 Nov '04  
GeneralUsing this in a DIALOG PinmemberAlex Evans20:44 27 Sep '04  
GeneralProblems trying CEGL in a x86 PinsussJordi Ros4:30 24 Aug '04  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 24 Jun 2002
Editor: Chris Maunder
Copyright 2002 by Jie Tang
Everything else Copyright © CodeProject, 1999-2009
Web20 | Advertise on the Code Project