30 const QRgb transp = qRgba(0, 0, 0, 0);
31 const QRgb blackline = qRgba(1, 1, 1, 255);
32 const QRgb redline = qRgba(254,0,0,255);
33 const QRgb greenline = qRgba(0,254,0,255);
34 const QRgb blueline = qRgba(0,0,254,255);
59 quint64 memoryUsage()
override;
65 void setImage(
QImage* pImg);
72 void moveTopLeft(
QPoint point);
74 void transform(
QRect rectangle,
bool smoothTransform);
75 void transform(
QRectF rectangle,
bool smoothTransform) { transform(rectangle.toRect(), smoothTransform); }
78 BitmapImage transformed(
QRectF rectangle,
bool smoothTransform) {
return transformed(rectangle.toRect(), smoothTransform); }
84 QRgb pixel(
int x,
int y);
86 void setPixel(
int x,
int y, QRgb color);
87 void setPixel(
QPoint p, QRgb color);
88 void fillNonAlphaPixels(
const QRgb color);
90 QRgb constScanLine(
int x,
int y)
const;
91 void scanLine(
int x,
int y, QRgb color);
93 void clear(
QRect rectangle);
94 void clear(
QRectF rectangle) { clear(rectangle.
toRect()); }
96 static bool floodFill(
BitmapImage** replaceImage,
const BitmapImage* targetImage,
const QRect& cameraRect,
const QPoint& point,
const QRgb& fillColor,
int tolerance,
const int expandValue);
97 static bool* floodFillPoints(
const BitmapImage* targetImage,
98 const QRect& searchBounds,
102 static void expandFill(
bool* fillPixels,
const QRect& searchBounds,
const QRect& maxBounds,
int expand);
121 BitmapImage* scanToTransparent(
BitmapImage* img,
int threshold,
bool redEnabled,
bool greenEnabled,
bool blueEnabled);
136 void enableAutoCrop(
bool b) { mEnableAutoCrop = b; }
137 void setOpacity(qreal opacity) { mOpacity = opacity; }
138 qreal getOpacity()
const {
return mOpacity; }
159 if (newColor == oldColor)
return true;
161 if(cache && cache->
contains(newColor))
return cache->
value(newColor);
166 int diffRed =
static_cast<int>(qPow(qRed(oldColor) - qRed(newColor), 2));
167 int diffGreen =
static_cast<int>(qPow(qGreen(oldColor) - qGreen(newColor), 2));
168 int diffBlue =
static_cast<int>(qPow(qBlue(oldColor) - qBlue(newColor), 2));
171 int diffAlpha =
static_cast<int>(qPow(qAlpha(oldColor) - qAlpha(newColor), 2));
173 bool isSimilar = (diffRed + diffGreen + diffBlue + diffAlpha) <= tolerance;
177 Q_ASSERT(cache->
contains(isSimilar) ? isSimilar == (*cache)[newColor] :
true);
178 (*cache)[newColor] = isSimilar;
186 void extend(
const QPoint& p);
187 void extend(
QRect rectangle);
194 QRect mBounds{0, 0, 0, 0};
198 bool mEnableAutoCrop =
false;
200 const int LOW_THRESHOLD = 30;
201 const int COLORDIFF = 5;
202 const int GRAYSCALEDIFF = 15;
204 qreal mOpacity = 1.0;
void updateBounds(QRect rectangle)
Update image bounds.
void loadFile() override
Loads the backing image data from disk and into memory if it exists but hasn't been loaded yet.
bool isLoaded() const override
Checks whether the keyframe holds valid image data.
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.
void unloadFile() override
Unloads the image data from memory if there's valid backing data on disk and the latest state has bee...
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