Graphics

Choosing the right graphics framework

BlackBerry® devices support many graphics frameworks. Before you start doing any graphics programming for BlackBerrydevices, it's important that you understand the frameworks that are available to you. By gaining an understanding of these frameworks, you can pick the one that best fits your application programming needs, while also taking into consideration possible future requirements of your application. Making a poor choice at the beginning could result in rework later.

The graphics frameworks supported by BlackBerry devices fall into three categories: hardware-accelerated APIs, web and vector graphics APIs, and canvas graphics APIs.

Hardware-accelerated APIs

OpenGL® ES 1.1 and 2.0 and OpenVG™ are the frameworks in this category. All BlackBerry 7devices have dedicated graphics hardware. To realize the benefits of that hardware, you should use hardware-accelerated APIs.

You use OpenGL ES to create real-time, accelerated 3D and 2D graphics. If you're creating a cutting edge first-person shooter game, an amazing data visualization app, or a 3D marker for your augmented reality application, you should be using OpenGL ES.

OpenVG™ produces hardware-accelerated vector graphics, which are described in the next section.

Web and vector graphics APIs

SVG and OpenVG are the frameworks in this category.

SVG is a good choice if you have existing, static content or web-based content that you need to scale. Although the BlackBerry JDK includes a JSR 226 compliant implementation of SVG Tiny™ (1.1/1.2), the BrowserField class actually supports SVG 1.1 (full) so we recommend you use that instead.

OpenVG is well-suited to programmatically performing immediate mode rendering of dynamic vector graphics. Use OpenVG, for example, for graphics and scalable content that must be precisely located. A weather overlay for example, or high-quality scaled text like you would see in a PDF viewer or an eBook application.

Canvas graphics APIs

BlackBerry UI graphics and MIDlet LCD graphics are the frameworks in this category.

Canvas graphics APIs provide you with basic 2D graphic functionality. Because these APIs are limited in functionality and aren't designed to make optimal use of the latest graphics hardware, there are really only two situations when choosing to use canvas graphics is the best choice. The first is if you are overriding the paint() method to customize a UI component. The second is if you are working with legacy code or a MIDlet.

Namespaces of graphics APIs

Graphics API Namespace

OpenGL ES (1.1/2.0)

javax.microedition.khronos.opengles

net.rim.device.api.opengles

OpenVG

net.rim.device.api.openvg

SVG Tiny

javax.microedition.m2g

SVG 1.1 (full) / BrowserField

net.rim.device.api.browser.field2

BlackBerry UI graphics

net.rim.device.api.ui

MIDlet LCD graphics

net.rim.device.api.lcdui

Next topic: OpenGL ES

Was this information helpful? Send us your comments.