Powerful two-dimensional graphics engine of. NET Compact Framework

Source: Internet
Author: User

Introduction
For mobile devices,. NET Compact Framework is an excellent API even if it is not the best API. Its graphics engine is heavily restricted to improve rendering speed and reduce memory consumption. However, it seems far from meeting the increasing requirements of users for better graphic experience. It may be a tedious task to try to obtain some advanced vector graphics rendering functions in. NET Compact Framework. Developers have two options:

1. Turn to the local code. For example, the Pocket PC Game API may be a good choice. Its performance is impressive. For more information, see a very comprehensive article at: http://msdn.microsoft.com/mobility/samples/default.aspx? Pull =/library/en-us/dnnetcomp/html/gmangame. asp. The problem is that the local code does not support vector graphics rendering and is not compatible with some devices. In addition, it may not work with the Pocket PC simulation program. You can imagine how difficult it is to debug such a program.

2. Please wait for the next generation of mobile graphics engine to come out. As far as I know, Windows CE 5 will contain a powerful Direct3D Mobile engine. This is good news for mobile game developers, but Direct3D is not suitable for 2D graphics. It is too complex to be applied in general applications.

What we need is a powerful and easy-to-use two-dimensional graphics engine like GDI +. Therefore, I have developed the xrosone GDI + project from scratch. It is fully written in C #-managed code and does not contain any local code or insecure code. After several months of hard work, I can finally provide the original downloadable version at the beginning of this article.

Start work
Since the beginning of this project, I have always remembered that the xrosone GDI + engine should be neutral to different handheld devices and platforms. As a result, it can be compatible with Pocket PC, Windows CE, Smartphones, Windows. NET, and Mono. You can copy the same Runtime Library to different targets, but it still works properly.

The following table summarizes the overall architecture.

Layer namespace
Xrosone GDI + API xrosone. Drawing
Point-based two-dimensional graphics engine xrosone. drawingreen
16.16 fixed-point computing engine xrosone. FixedPoint

Xrosone GDI + has three layers. The lowest layer is "16.16 fixed point computing engine ". One of the main classes-MathFP-is adapted from the beartrow.j2s library. Some functions have been optimized, including sqrt, atan, and PointFP. Distancecalculation. Under the namespace xrosone. FixedPoint, there are three other classes: SingleFP, DoubleFP, and MatrixFP. SingleFP is a Helper class used for 16.16 points. It facilitates the conversion between the fixed point type and the standard type (int, float, string. MatrixFP is written for fixed point two-dimensional transformation. Because the precision of fixed point calculation is low, cascade transformation may lose some accuracy. For example, in most cases, two reverse operations cannot restore the original matrix. DoubleFP exists to make the database complete, but it is not used yet.

The "fixed-point-based two-dimensional graphics engine" is the kernel of xrosone GDI +. It implements many complex vector graphics algorithms, such as anti-sawtooth plotting, line caps/link decoration, two-dimensional transformation, gradient filling, Alpha channel synthesis, and so on. Most advanced functions in the local GDI + are found here. However, you should only use it directly in a few cases, because its fixed-point-based interface is not friendly to programmers, but you do not have to worry about this situation. There is a well-encapsulated API for use. You can find them in the xrosone. Drawing namespace. The classes in xrosone. Drawing are very similar to the classes in System. Drawing. The difference is that there is a letter "X" at the end of each class ". For example, the xrosone. Drawing. PenX class is equivalent to System. Drawing. Pen. There is a tip for converting a GDI + program to xrosone GDI +. In the using section, rename the xrosone GDI + classes to their equivalent classes. For example:

Using Pen = xrosone. Drawing. PenX;
Using LinearGradientBrush = xrosone. Drawing. LinearGradientBrushX;
Using Matrix = xrosone. Drawing. MatrixX;

This topic consists of five pages, currently on page 1 2 3 4 5


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.