All Classes Namespaces Functions Variables Enumerations Properties Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | List of all members
BitmapImage Class Reference
+ Inheritance diagram for BitmapImage:

Public Member Functions

 BitmapImage (const BitmapImage &)
 
 BitmapImage (const QRect &rectangle, const QColor &color)
 
 BitmapImage (const QPoint &topLeft, const QImage &image)
 
 BitmapImage (const QPoint &topLeft, const QString &path)
 
BitmapImageoperator= (const BitmapImage &a)
 
BitmapImageclone () const override
 
void loadFile () override
 
void unloadFile () override
 
bool isLoaded () const override
 
quint64 memoryUsage () override
 
void paintImage (QPainter &painter)
 
void paintImage (QPainter &painter, QImage &image, QRect sourceRect, QRect destRect)
 
QImageimage ()
 
void setImage (QImage *pImg)
 
BitmapImage copy ()
 
BitmapImage copy (QRect rectangle)
 
void paste (BitmapImage *, QPainter::CompositionMode cm=QPainter::CompositionMode_SourceOver)
 
void moveTopLeft (QPoint point)
 
void moveTopLeft (QPointF point)
 
void transform (QRect rectangle, bool smoothTransform)
 
void transform (QRectF rectangle, bool smoothTransform)
 
BitmapImage transformed (QRect selection, QTransform transform, bool smoothTransform)
 
BitmapImage transformed (QRect rectangle, bool smoothTransform)
 
BitmapImage transformed (QRectF rectangle, bool smoothTransform)
 
bool contains (QPoint P)
 
bool contains (QPointF P)
 
void autoCrop ()
 Removes any transparent borders by reducing the boundaries. More...
 
QRgb pixel (int x, int y)
 
QRgb pixel (QPoint p)
 
void setPixel (int x, int y, QRgb color)
 
void setPixel (QPoint p, QRgb color)
 
void fillNonAlphaPixels (const QRgb color)
 
QRgb constScanLine (int x, int y) const
 
void scanLine (int x, int y, QRgb color)
 
void clear ()
 
void clear (QRect rectangle)
 
void clear (QRectF rectangle)
 
void drawLine (QPointF P1, QPointF P2, QPen pen, QPainter::CompositionMode cm, bool antialiasing)
 
void drawRect (QRectF rectangle, QPen pen, QBrush brush, QPainter::CompositionMode cm, bool antialiasing)
 
void drawEllipse (QRectF rectangle, QPen pen, QBrush brush, QPainter::CompositionMode cm, bool antialiasing)
 
void drawPath (QPainterPath path, QPen pen, QBrush brush, QPainter::CompositionMode cm, bool antialiasing)
 
QPoint topLeft ()
 
QPoint topRight ()
 
QPoint bottomLeft ()
 
QPoint bottomRight ()
 
int left ()
 
int right ()
 
int top ()
 
int bottom ()
 
int width ()
 
int height ()
 
QSize size ()
 
QRectbounds ()
 
bool isMinimallyBounded () const
 Determines if the BitmapImage is minimally bounded. More...
 
void enableAutoCrop (bool b)
 
void setOpacity (qreal opacity)
 
qreal getOpacity () const
 
Status writeFile (const QString &filename)
 
- Public Member Functions inherited from KeyFrame
 KeyFrame (const KeyFrame &k2)
 
KeyFrameoperator= (const KeyFrame &k2)
 
int pos () const
 
void setPos (int position)
 
int length () const
 
void setLength (int len)
 
void modification ()
 
void setModified (bool b)
 
bool isModified () const
 
void setSelected (bool b)
 
bool isSelected () const
 
QString fileName () const
 
void setFileName (QString strFileName)
 
void addEventListener (KeyFrameEventListener *)
 
void removeEventListner (KeyFrameEventListener *)
 

Static Public Member Functions

static bool floodFill (BitmapImage **replaceImage, const BitmapImage *targetImage, const QRect &cameraRect, const QPoint &point, const QRgb &fillColor, int tolerance, const int expandValue)
 
static bool * floodFillPoints (const BitmapImage *targetImage, QRect searchBounds, const QRect &maxBounds, QPoint point, const int tolerance, QRect &newBounds, bool &fillBorder)
 
static void expandFill (bool *fillPixels, const QRect &searchBounds, const QRect &maxBounds, int expand)
 Finds all pixels closest to the input color and applies the input color to the image. More...
 
static bool compareColor (QRgb newColor, QRgb oldColor, int tolerance, QHash< QRgb, bool > *cache)
 Compare colors for the purposes of flood filling. More...
 

Protected Member Functions

void updateBounds (QRect rectangle)
 Update image bounds. More...
 
void extend (const QPoint &p)
 
void extend (QRect rectangle)
 
void setCompositionModeBounds (BitmapImage *source, QPainter::CompositionMode cm)
 Updates the bounds after a drawImage operation with the composition mode cm. More...
 
void setCompositionModeBounds (QRect sourceBounds, bool isSourceMinBounds, QPainter::CompositionMode cm)
 Updates the bounds after a draw operation with the composition mode cm. More...
 

Private Attributes

QImage mImage
 
QRect mBounds
 
QRect bool mMinBound = true
 
bool mEnableAutoCrop = false
 
qreal mOpacity = 1.0
 

Detailed Description

Definition at line 26 of file bitmapimage.h.

Member Function Documentation

void BitmapImage::autoCrop ( )

Removes any transparent borders by reducing the boundaries.

This function reduces the bounds of an image until the top and bottom rows, and the left and right columns of pixels each contain at least one pixel with a non-zero alpha value (i.e. non-transparent pixel). Both mBounds and the size of #mImage are updated.

Precondition
mBounds.size() == mImage->size()
Postcondition
Either the first and last rows and columns all contain a pixel with alpha > 0 or mBounds.isEmpty() == true
isMinimallyBounded() == true

Definition at line 402 of file bitmapimage.cpp.

static bool BitmapImage::compareColor ( QRgb  newColor,
QRgb  oldColor,
int  tolerance,
QHash< QRgb, bool > *  cache 
)
inlinestatic

Compare colors for the purposes of flood filling.

Calculates the Eulcidian difference of the RGB channels of the image and compares it to the tolerance

Parameters
[in]newColorThe first color to compare
[in]oldColorThe second color to compare
[in]toleranceThe threshold limit between a matching and non-matching color
[in,out]cacheContains a mapping of previous results of compareColor with rule that cache[someColor] = compareColor(someColor, oldColor, tolerance)
Returns
Returns true if the colors have a similarity below the tolerance level (i.e. if Eulcidian distance squared is <= tolerance)

Definition at line 138 of file bitmapimage.h.

void BitmapImage::expandFill ( bool *  fillPixels,
const QRect searchBounds,
const QRect maxBounds,
int  expand 
)
static

Finds all pixels closest to the input color and applies the input color to the image.

An example:

0 is where the color was found 1 is the distance from the nearest pixel of that color

211112 100001 100001 211112

Parameters
bitmapImageImage to search
searchColorColor to find

Definition at line 968 of file bitmapimage.cpp.

bool BitmapImage::isMinimallyBounded ( ) const
inline

Determines if the BitmapImage is minimally bounded.

A BitmapImage is minimally bounded if all edges contain at least 1 non-transparent pixel (alpha > 0). In other words, the size of the image cannot be decreased without cropping visible data.

Returns
True only if bounds() is the minimal bounding box for the contained image.

Definition at line 117 of file bitmapimage.h.

void BitmapImage::setCompositionModeBounds ( BitmapImage source,
QPainter::CompositionMode  cm 
)
protected

Updates the bounds after a drawImage operation with the composition mode cm.

Parameters
[in]sourceThe source image used for the drawImage call.
[in]cmThe composition mode that will be used for the draw image
See Also
BitmapImage::setCompositionModeBounds(BitmapImage, QPainter::CompositionMode)

Definition at line 330 of file bitmapimage.cpp.

void BitmapImage::setCompositionModeBounds ( QRect  sourceBounds,
bool  isSourceMinBounds,
QPainter::CompositionMode  cm 
)
protected

Updates the bounds after a draw operation with the composition mode cm.

Parameters
[in]sourceBoundsThe bounds of the source used for drawcall.
[in]isSourceMinBoundsIs sourceBounds the minimal bounds for the source image
[in]cmThe composition mode that will be used for the draw image

For a call to draw image of a QPainter (initialized with mImage) with an argument of source, this function intelligently calculates the bounds. It will attempt to preserve minimum bounds based on the composition mode.

This works baed on the principle that some minimal bounds can be determined solely by the minimal bounds of this and source, depending on the value of cm. Some composition modes only expand, or have no affect on the bounds.

Warning
The draw operation described by the arguments of this function needs to be called after this function is run, or the bounds will be out of sync. If mBounds is null, no draw operation needs to be performed.

Definition at line 357 of file bitmapimage.cpp.

void BitmapImage::updateBounds ( QRect  newBoundaries)
protected

Update image bounds.

Parameters
[in]newBoundariesthe new bounds

Sets this image's bounds to rectangle. Modifies mBounds and crops mImage.

Definition at line 269 of file bitmapimage.cpp.

Member Data Documentation

QRect bool BitmapImage::mMinBound = true
private
See Also
isMinimallyBounded()

Definition at line 179 of file bitmapimage.h.


The documentation for this class was generated from the following files: