41 void loadFile()
override;
42 void unloadFile()
override;
43 bool isLoaded()
const override;
44 quint64 memoryUsage()
override;
50 void setImage(
QImage* pImg);
57 void moveTopLeft(
QPoint point);
59 void transform(
QRect rectangle,
bool smoothTransform);
60 void transform(
QRectF rectangle,
bool smoothTransform) { transform(rectangle.toRect(), smoothTransform); }
63 BitmapImage transformed(
QRectF rectangle,
bool smoothTransform) {
return transformed(rectangle.toRect(), smoothTransform); }
69 QRgb pixel(
int x,
int y);
71 void setPixel(
int x,
int y, QRgb color);
72 void setPixel(
QPoint p, QRgb color);
73 void fillNonAlphaPixels(
const QRgb color);
75 QRgb constScanLine(
int x,
int y)
const;
76 void scanLine(
int x,
int y, QRgb color);
78 void clear(
QRect rectangle);
79 void clear(
QRectF rectangle) { clear(rectangle.
toRect()); }
81 static bool floodFill(
BitmapImage** replaceImage,
const BitmapImage* targetImage,
const QRect& cameraRect,
const QPoint& point,
const QRgb& fillColor,
int tolerance,
const int expandValue);
82 static bool* floodFillPoints(
const BitmapImage* targetImage,
88 static void expandFill(
bool* fillPixels,
const QRect& searchBounds,
const QRect& maxBounds,
int expand);
121 void enableAutoCrop(
bool b) { mEnableAutoCrop = b; }
122 void setOpacity(qreal opacity) { mOpacity = opacity; }
123 qreal getOpacity()
const {
return mOpacity; }
144 if (newColor == oldColor)
return true;
146 if(cache && cache->
contains(newColor))
return cache->
value(newColor);
151 int diffRed =
static_cast<int>(qPow(qRed(oldColor) - qRed(newColor), 2));
152 int diffGreen =
static_cast<int>(qPow(qGreen(oldColor) - qGreen(newColor), 2));
153 int diffBlue =
static_cast<int>(qPow(qBlue(oldColor) - qBlue(newColor), 2));
156 int diffAlpha =
static_cast<int>(qPow(qAlpha(oldColor) - qAlpha(newColor), 2));
158 bool isSimilar = (diffRed + diffGreen + diffBlue + diffAlpha) <= tolerance;
162 Q_ASSERT(cache->
contains(isSimilar) ? isSimilar == (*cache)[newColor] :
true);
163 (*cache)[newColor] = isSimilar;
171 void extend(
const QPoint& p);
172 void extend(
QRect rectangle);
179 QRect mBounds{0, 0, 0, 0};
183 bool mEnableAutoCrop =
false;
184 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