Home · All Classes · Main Classes · Deprecated
Public Member Functions | Protected Member Functions | Protected Attributes

MScalableImage Class Reference

MScalableImage is a class for drawing scaled pixmaps into screen without breaking the boundaries of the image. More...

Inherits QObject.

List of all members.

Public Member Functions

 MScalableImage ()
 MScalableImage (const QPixmap *pixmap, int left, int right, int top, int bottom, const QString &pixmapId="")
virtual ~MScalableImage ()
void borders (int *left, int *right, int *top, int *bottom) const
void setBorders (int left, int right, int top, int bottom)
const QTileRulestileRules () const
void setTileRules (const QTileRules &tileRules)
void setPixmap (const QPixmap *pixmap)
const QPixmappixmap () const
void draw (int x, int y, int w, int h, QPainter *painter) const
void draw (const QPoint &pos, const QSize &size, QPainter *painter) const
void draw (const QRect &rect, QPainter *painter) const
void draw (qreal x, qreal y, qreal w, qreal h, QPainter *painter) const
void draw (const QPointF &pos, const QSizeF &size, QPainter *painter) const
void draw (const QRectF &rect, QPainter *painter) const
void enableOptimizedRendering (bool enable)
void draw (const QRect &rect, const QPoint &pixmapOffset, const QPixmap *pixmap, QPainter *painter) const

Protected Member Functions

 MScalableImage (MScalableImagePrivate *dd)

Protected Attributes

MScalableImagePrivate *const d_ptr

Detailed Description

MScalableImage is a class for drawing scaled pixmaps into screen without breaking the boundaries of the image.

The image is constructed from 9 blocks and it is scalable in every direction.

<corner> <h_edge> <corner> <v_edge> <center> <v_edge> <corner> <h_edge> <corner>

The scalable area of the image is defined using the left, right, top and bottom border parameters. The borders are defined as pixels and they cannot be larger than the used source pixmap.

The corner blocks are not scaled at all. The horizontal edges (h_edge) are scaled only horizontally and the vertical edges (v_edge) only vertically. The center block is scaled vertically and horizontally if needed. The size inputted into one the draw() methods cannot be smaller than the defined borders.

Note:
Due to a known bug in Qt 4.7 trying to render a scaled image with the defined borders resulting in empty blocks (zero borders or borders covering the entire image) can result in graphical glitches in certain cases. The image will be rendered with automatically adjusted borders in such situations. Zero borders will be adjusted to 1 and borders covering the entire image will be reduced.

Constructor & Destructor Documentation

MScalableImage::MScalableImage (  ) 

Default constructor. Initiates pixmap and borders to 0.

MScalableImage::MScalableImage ( const QPixmap pixmap,
int  left,
int  right,
int  top,
int  bottom,
const QString pixmapId = "" 
)

Constructor. Initiates pixmap and borders to inputted values.

Parameters:
pixmapId - optional pixmapId associated with a scalable image which will be included into warnings if MScalableImage happen to find those
MScalableImage::~MScalableImage (  )  [virtual]

Destructor.

MScalableImage::MScalableImage ( MScalableImagePrivate *  dd  )  [protected]

Member Function Documentation

void MScalableImage::borders ( int *  left,
int *  right,
int *  top,
int *  bottom 
) const

Get borders for the image.

The borders are defined as pixels. See createScalable() for description about how the borders affect to the image drawing/scaling.

void MScalableImage::draw ( const QPoint pos,
const QSize size,
QPainter painter 
) const

Draws scalable image.This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void MScalableImage::draw ( const QRect rect,
QPainter painter 
) const

Draws scalable image.This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void MScalableImage::draw ( qreal  x,
qreal  y,
qreal  w,
qreal  h,
QPainter painter 
) const

Draws scalable image.This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void MScalableImage::draw ( const QPointF pos,
const QSizeF size,
QPainter painter 
) const

Draws scalable image.This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void MScalableImage::draw ( int  x,
int  y,
int  w,
int  h,
QPainter painter 
) const

Draws scalable image.

The image is drawn starting from the topleft corner defined by the x and y coordinates. The image is scaled to fit the w and h. Scaling follows the rules defined in the createScalable() method.

If -1 is defined as w or h appropriate value from the image is used so no scaling takes place.

void MScalableImage::draw ( const QRectF rect,
QPainter painter 
) const

Draws scalable image.This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void MScalableImage::draw ( const QRect rect,
const QPoint pixmapOffset,
const QPixmap pixmap,
QPainter painter 
) const

Draws the scalable image using color channel from pixmap and alpha channel from scalable image.

Parameters:
rect Target rectangle, where scalable image is drawn into.
pixmapOffset Start sampling offset of the pixmap to be filled.
pixmap Pixmap to be used for filling the opaque areas of the scalable image, this can be NULL.
painter Painter to be used for drawing.
void MScalableImage::enableOptimizedRendering ( bool  enable  ) 

Enable/disable optimized rendering.

If enable is true, the image patches are packed into one vertex array and it is rendered with one glDrawArray call. If enable is false, the image patches are rendered separately.

Note:
This method is only for benchmarking purposes and may be removed in the future.
Deprecated:
const QPixmap * MScalableImage::pixmap (  )  const

Returns the pixmap that was given as parameter into the createScalable() or setPixmap() methods.

void MScalableImage::setBorders ( int  left,
int  right,
int  top,
int  bottom 
)

Set borders for the image.

The borders are defined as pixels. See createScalable() for description about how the borders affect to the image drawing/scaling.

void MScalableImage::setPixmap ( const QPixmap pixmap  ) 

Set/change the drawn pixmap.

The ownership of pixmap is not changed by this method, the caller of the method is still responsible for releasing the pixmap after done using it.

void MScalableImage::setTileRules ( const QTileRules tileRules  ) 

Set tiling rulest for the image.

By default, the horizontal and vertical tile rules are set to Qt::StretchTile. See QTileRules documentation for more details.

const QTileRules & MScalableImage::tileRules (  )  const

Get tiling rules of the image.


Member Data Documentation

MScalableImagePrivate* const MScalableImage::d_ptr [protected]

Copyright © 2010 Nokia Corporation
MeeGo Touch