39 void loadFile()
override;
40 void unloadFile()
override;
41 bool isLoaded()
const override;
42 quint64 memoryUsage()
override;
48 void setImage(
QImage* pImg);
54 void moveTopLeft(
QPoint point);
56 void transform(
QRect rectangle,
bool smoothTransform);
57 void transform(
QRectF rectangle,
bool smoothTransform) { transform(rectangle.toRect(), smoothTransform); }
60 BitmapImage transformed(
QRectF rectangle,
bool smoothTransform) {
return transformed(rectangle.toRect(), smoothTransform); }
66 QRgb pixel(
int x,
int y);
68 void setPixel(
int x,
int y, QRgb color);
69 void setPixel(
QPoint p, QRgb color);
70 void fillNonAlphaPixels(
const QRgb color);
72 QRgb constScanLine(
int x,
int y)
const;
73 void scanLine(
int x,
int y, QRgb color);
75 void clear(
QRect rectangle);
76 void clear(
QRectF rectangle) { clear(rectangle.
toRect()); }
78 static bool floodFill(
BitmapImage** replaceImage,
const BitmapImage* targetImage,
const QRect& cameraRect,
const QPoint& point,
const QRgb& fillColor,
int tolerance,
const int expandValue);
79 static bool* floodFillPoints(
const BitmapImage* targetImage,
85 static void expandFill(
bool* fillPixels,
const QRect& searchBounds,
const QRect& maxBounds,
int expand);
118 void enableAutoCrop(
bool b) { mEnableAutoCrop = b; }
119 void setOpacity(qreal opacity) { mOpacity = opacity; }
120 qreal getOpacity()
const {
return mOpacity; }
141 if (newColor == oldColor)
return true;
143 if(cache && cache->
contains(newColor))
return cache->
value(newColor);
148 int diffRed =
static_cast<int>(qPow(qRed(oldColor) - qRed(newColor), 2));
149 int diffGreen =
static_cast<int>(qPow(qGreen(oldColor) - qGreen(newColor), 2));
150 int diffBlue =
static_cast<int>(qPow(qBlue(oldColor) - qBlue(newColor), 2));
153 int diffAlpha =
static_cast<int>(qPow(qAlpha(oldColor) - qAlpha(newColor), 2));
155 bool isSimilar = (diffRed + diffGreen + diffBlue + diffAlpha) <= tolerance;
159 Q_ASSERT(cache->
contains(isSimilar) ? isSimilar == (*cache)[newColor] :
true);
160 (*cache)[newColor] = isSimilar;
168 void extend(
const QPoint& p);
169 void extend(
QRect rectangle);
176 QRect mBounds{0, 0, 0, 0};
180 bool mEnableAutoCrop =
false;
181 qreal mOpacity = 1.0;
void updateBounds(QRect rectangle)
Update image bounds.
void setCompositionModeBounds(BitmapImage *source, QPainter::CompositionMode cm)
Updates the bounds after a drawImage operation with the composition mode cm.
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.
void autoCrop()
Removes any transparent borders by reducing the boundaries.
static bool compareColor(QRgb newColor, QRgb oldColor, int tolerance, QHash< QRgb, bool > *cache)
Compare colors for the purposes of flood filling.
bool isMinimallyBounded() const
Determines if the BitmapImage is minimally bounded.
bool contains(const Key &key) const const
const T value(const Key &key) const const
QPoint toPoint() const const
QPoint bottomLeft() const const
QPoint bottomRight() const const
bool contains(const QRect &rectangle, bool proper) const const
QPoint topLeft() const const
QPoint topRight() const const
QRect toRect() const const