Introduction

CEDraw is high speed graphics library in WinCE . it¡¯s depend on GAPI .
This code was writen in C++ and using embedded VC++ to complie it. Testing in iPaq h3600 with WinCE 3.0.
CEDraw use double buffer and direct write video buffer technology to enhance Draw speed. With own graphics arithmetic, the draw speed is much more faster than WinGDI.

CE Draw support those function:

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 )


SDKSample Screen Shot:(screenshot.jpg)


How to using 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 system,copy two of the dll in ¡­\CEGraph\DLL\X86Em directory ( gx.dll & cegl.dll) to
emulation windows system directory, always in D:\Windows CE Tools\wce300\MS Pocket PC\emulation\palm300\windows
Then copy the file Hzk16 which in ¡­\CEGraph\Res directory to the WinCE Root directory.
Always in D:\Windows CE Tools\wce300\MS Pocket PC\emulation\palm300

(2) if Using in Arm system,copy two fo the dll in ¡­\CEGraph\DLL\Arm ( gx.dll & cegl.dll) to 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;

// Initlizate 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;
cePen.CreatePen( 1, 1, m_ceDraw.ConvertColor( 255, 0, 0 ) );
// Convert RGB color to CE support Color

// 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;
ceBmp1.LoadBitmap( &m_ceDraw, L"windows\\wcelogo1.gif" );     
// Load Gif picture from file
ceBmp2.LoadBitmap( &m_ceDraw, L"windows\\welcomehead.gif" );
ceBmp2.BitBlt( &m_ceDraw, 1, 80, 0, 0, 0, 0, SRCALPHA, 0.6f );
// Draw bitmap with alpha blend
ceBmp1.BitBlt( &m_ceDraw, 1, 200, 0, 0, 0, 0, SRCALPHA, 0.6f );

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

// 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 can not be directly used in MFC appwizard generated frame. Because it has two window, One is frame window, the other is child Window.
I¡¯v write a Frame Code that support MFC. If anyone who want to use it in mfc. Write mail to me.
¡¡

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 )


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

Thanks

This Code using GAPI Enum. Thanks to the Writer.






¡¡