#include <ZSurface.h>
Inheritance diagram for ZSurface:

Public Types | |
| enum | ZROTATION { Z0, Z90, Z270 } |
Public Methods | |
| ZSurface () | |
| ZSurface (int w, int h, bool alpha=false) | |
| ZSurface (const QImage &img, bool alpha=false) | |
| ZSurface (const QPixmap &pix, bool alpha=false) | |
| ZSurface (const ZSurface &) | |
| virtual | ~ZSurface () |
| ZSurface & | operator= (const ZSurface &z) |
| virtual bool | create (const QImage &, bool alpha=false) |
| virtual bool | create (const QPixmap &, bool alpha=false) |
| virtual bool | create (int width, int height, bool alpha=false) |
| void | fill (QColor clr) |
| bool | drawLine (int x1, int y1, int x2, int y2, QColor clr) |
| bool | drawLineBlend (int x1, int y1, int x2, int y2, QColor clr, int opacity) |
| int | ZSurface::drawText (int dx, int ny, const QString &s, ZFont *f, int opacity=32) |
| int | ZSurface::drawText (int dx, int ny, const QString &s, ZFont *f, QColor c, int opacity=32) |
| bool | isValid () const |
| bool | hasAlpha () const |
| int | width () const |
| int | size () const |
| int | scanlineWidth () const |
| int | height () const |
| int | depth () const |
| void | setPixel (int x, int y, const QColor &c) |
| void | getPixel (int x, int y, QColor &c) |
| unsigned short * | bits () |
| unsigned short * | alpha () |
Static Public Methods | |
| ZROTATION | rotation () |
| void | setRotation (ZROTATION zr) |
| bool | bitBlit (QDirectPainter *dst, const ZSurface *src, ZROTATION r) |
| bool | bitBlit (ZSurface *dst, int dx, int dy, const ZSurface *src, int sx=0, int sy=0, int sw=-1, int sh=-1) |
| bool | bitBlitBlend (int opacity, ZSurface *dst, int dx, int dy, const ZSurface *src, int sx=0, int sy=0, int sw=-1, int sh=-1) |
| bool | bitBlitAlpha (ZSurface *dst, int dx, int dy, const ZSurface *src, int sx=0, int sy=0, int sw=-1, int sh=-1) |
| bool | bitBlitKeyed (ZSurface *dst, int dx, int dy, const QColor &key, const ZSurface *src, int sx=0, int sy=0, int sw=-1, int sh=-1) |
| bool | bitBlitKeyedBlend (int opacity, ZSurface *dst, int dx, int dy, const QColor &key, const ZSurface *src, int sx=0, int sy=0, int sw=-1, int sh=-1) |
| bool | fillBlitKeyed (ZSurface *dst, int dx, int dy, const QColor &key, const QColor &fillColor, const ZSurface *src, int sx=0, int sy=0, int sw=-1, int sh=-1) |
| bool | fillBlitKeyedBlend (int opacity, ZSurface *dst, int dx, int dy, const QColor &key, const QColor &fillColor, const ZSurface *src, int sx=0, int sy=0, int sw=-1, int sh=-1) |
| bool | fillRect (ZSurface *dst, int dx, int dy, int rw, int rh, const QColor &clr) |
| bool | fillRectBlend (int opacity, ZSurface *dst, int dx, int dy, int rw, int rh, const QColor &clr) |
Protected Methods | |
| void | initFromImage (const QImage &i) |
It provides set of optimized methods for various types of memory transfers ( blitting) between memory buffers (ZSurfaces) and/or framebuffer (video) memory on ARM powered, qte based devices.
Each ZSurface object has a memory buffer associated with it and , optionally, a alpha channel buffer which specifies the transparency of a pixel. 0 means completely transparent and 255 means opaque.
A surface has the parameters width(), height() and the actual pixels and alpha data.
It can be initialized using an existing QImage or QPixmap object.
Generally there are two kinds of methods available:
1) You would create your main window ( just like any other qte based application.)
2) At this point ZSurface only supports full-screen application/games and therefore your next step would be to switch your application into full screen mode ( refer to the example code or this page for more information about this subject)
3) Next you would create backbuffer ZSurface which MUST be the same size as your screen (240x320 at this point.)
4) Load/create all other ZSurfaces for your sprites/objects etc ...
5) Create some sort of heartbeat function ( for example using QTimer) and draw all your images/sprites in that method using backbuffer surface as a destination.
6) At the end of that method call bitBlit(QDirectPainter *dst, const ZSurface *src,ZROTATION r) giving as a src your backbuffer surface.
This will blit content of your backbuffer to the framebuffer memory (display.)
Of course, as mentioned above you are free to do write any sort of code you want - as long as you can get your hands on QDirectPainter object to use it in your final blit to the screen memory, you are fine.
TO DO:
|
|
|
|
|
Constructs an invalid (null) ZSurface object. |
|
||||||||||||||||
|
Constructs a ZSurface object with w width, h height and alpha=false. |
|
||||||||||||
|
Constructs a ZSurface out of a valid QImage object. If alpha is set to true and the img object contains alpha channel data, this information will retained by the object (and later used by bitBlitAlpha.) |
|
||||||||||||
|
Constructs a ZSurface out of a valid QPixmap object. The Pixmap is used to create QImage object which then in turn is used to create ZSurface |
|
|
Constructs a deep copy of ZSurface object. |
|
|
Destroys the object and cleans up |
|
|
Returns a pointer to the alpha channel data. |
|
||||||||||||||||||||||||||||||||||||
|
Copies a block of pixels from src to dst surface. The sx,sy is the top left pixel in src (0,0) by default, dx,dy is the top left pixel in dst and sw,sh is the size of src (all of src by default.) |
|
||||||||||||||||
|
Copies a block of pixels from src to a valid QDirectPainter object using rotation r. The src ZSurface has to have the same size as the destination QDirectPainter object. This method should be used if you want to transfer content of the backbuffer ZSurface ( or any surface that has the same dimensions as the screen ) to the framebuffer (video) memory. |
|
||||||||||||||||||||||||||||||||||||
|
Copies a block of pixels from src to dst surface blending each pixel using alpha channel information from src. If the src surface does not contain alpha channel this call will have the same effect as bitBlit. |
|
||||||||||||||||||||||||||||||||||||||||
|
Copies a block of pixels from src to dst surface, blending each pixel using static alpha value opacity (0-32). |
|
||||||||||||||||||||||||||||||||||||||||
|
Copies a block of pixels from src to dst. For any src pixel matching QColor value key, the coresponding dst pixel will remain unchanged. |
|
||||||||||||||||||||||||||||||||||||||||||||
|
Copies a block of pixels from src to dst blending each pixel using static alpha value opacity (0-32). For any src pixel matching QColor value key, the coresponding dst pixel will remain unchanged. |
|
|
Returns a pointer to the pixel data. |
|
||||||||||||||||
|
Initializes an existing instance of ZSurface object with a given set of parameters. If the existing ZSurface object is a valid one and the size of the ZSurface doesn't change (w*h), the already allocated memory will be reused. If the object is invalid or the new size is different, a new memory block will be allocated and initialized with 0.If set to true,the alpha channel is initialized with 255(opaque) |
|
||||||||||||
|
Same as create(QImage ..) but using QPixmap as a source. If set to true, the alpha channel is initialized with 255 (opaque) |
|
||||||||||||
|
Initializes an existing instance of ZSurface object from a valid QImage. If the existing ZSurface object is a valid one and the size of the ZSurface doesn't change (w*h), the already allocated memory will be reused. If the object is invalid or the new size is different, a new memory block will be allocated and initialized with content of QImage. |
|
|
Returns depth of the surface (currently always 16). |
|
||||||||||||||||||||||||
|
Draws a line form (x1,y1) to (x2,y2) using the color value clr |
|
||||||||||||||||||||||||||||
|
Draws a line from (x1,y1) to (x2,y2) blending the color value clr with the existing pixels usign static alpha value opacity. |
|
|
Fills the entire surface with the color value clr (fast method) |
|
||||||||||||||||||||||||||||||||||||||||||||
|
Copies a block of pixels from src to dst using value of QColor fillColor to replace destination pixel. For any src pixel matching QColor value key,the coresponding dst pixel will remain unchanged. |
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
Copies a block of pixels from src to dst blending QColor value fillColor with a dst pixel using static alpha value opacity (0-32). For any src pixel matching QColor value key,the coresponding dst pixel will remain unchanged. |
|
||||||||||||||||||||||||||||
|
Fills the rectangle (dx,dy,rw,rh) with the QColor value clr. |
|
||||||||||||||||||||||||||||||||
|
Fills the rectangle (dx,dy,rw,rh) blending QColor value fillColor with the src pixels using static alpha value opacity (0-32). |
|
||||||||||||||||
|
Retrieves a color value of a single point at (x,y) into QColor reference c. |
|
|
Returns true if this ZSurface object has an alpha buffer associated with it. |
|
|
Returns the height of the surface in pixels. Reimplemented in ZFont. |
|
|
|
|
|
Returns true if this ZSurface object is valid ( has been properly initialized and has a valid memory block associated with it.) |
|
|
Assigns a deep copy of z to this ZSurface object and returns a reference to it. |
|
|
|
|
|
Returns the spacing in pixels from one line to the next. |
|
||||||||||||||||
|
Draws/Plots a single point at (x,y) using QColor value c. |
|
|
|
|
|
Returns the total size of the surface memory block in bytes ( scanlineWidth()*height()*(depth()/8) ). |
|
|
Returns the width of the surface in pixels. |
|
||||||||||||||||||||||||||||
|
Draws text on the surface using ZFont f, with a color value c, optionally blending with the surface pixels using static alpha opacity (0-32 , default 32 means no blending.) |
|
||||||||||||||||||||||||
|
Draws text on the surface using ZFont f, optionally blending with the surface pixels using static alpha opacity (0-32 , default 32 means no blending.) |
1.2.14 written by Dimitri van Heesch,
© 1997-2002