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);
46 void loadFile()
override;
47 void unloadFile()
override;
48 bool isLoaded()
const override;
49 quint64 memoryUsage()
override;
55 void setImage(
QImage* pImg);
62 void moveTopLeft(
QPoint point);
64 void transform(
QRect rectangle,
bool smoothTransform);
65 void transform(
QRectF rectangle,
bool smoothTransform) { transform(rectangle.toRect(), smoothTransform); }
68 BitmapImage transformed(
QRectF rectangle,
bool smoothTransform) {
return transformed(rectangle.toRect(), smoothTransform); }
74 QRgb pixel(
int x,
int y);
76 void setPixel(
int x,
int y, QRgb color);
77 void setPixel(
QPoint p, QRgb color);
78 void fillNonAlphaPixels(
const QRgb color);
80 QRgb constScanLine(
int x,
int y)
const;
81 void scanLine(
int x,
int y, QRgb color);
83 void clear(
QRect rectangle);
84 void clear(
QRectF rectangle) { clear(rectangle.
toRect()); }
86 static bool floodFill(
BitmapImage** replaceImage,
const BitmapImage* targetImage,
const QRect& cameraRect,
const QPoint& point,
const QRgb& fillColor,
int tolerance,
const int expandValue);
87 static bool* floodFillPoints(
const BitmapImage* targetImage,
88 const QRect& searchBounds,
92 static void expandFill(
bool* fillPixels,
const QRect& searchBounds,
const QRect& maxBounds,
int expand);
111 BitmapImage* scanToTransparent(
BitmapImage* img,
int threshold,
bool redEnabled,
bool greenEnabled,
bool blueEnabled);
126 void enableAutoCrop(
bool b) { mEnableAutoCrop = b; }
127 void setOpacity(qreal opacity) { mOpacity = opacity; }
128 qreal getOpacity()
const {
return mOpacity; }
149 if (newColor == oldColor)
return true;
151 if(cache && cache->
contains(newColor))
return cache->
value(newColor);
156 int diffRed =
static_cast<int>(qPow(qRed(oldColor) - qRed(newColor), 2));
157 int diffGreen =
static_cast<int>(qPow(qGreen(oldColor) - qGreen(newColor), 2));
158 int diffBlue =
static_cast<int>(qPow(qBlue(oldColor) - qBlue(newColor), 2));
161 int diffAlpha =
static_cast<int>(qPow(qAlpha(oldColor) - qAlpha(newColor), 2));
163 bool isSimilar = (diffRed + diffGreen + diffBlue + diffAlpha) <= tolerance;
167 Q_ASSERT(cache->
contains(isSimilar) ? isSimilar == (*cache)[newColor] :
true);
168 (*cache)[newColor] = isSimilar;
176 void extend(
const QPoint& p);
177 void extend(
QRect rectangle);
184 QRect mBounds{0, 0, 0, 0};
188 bool mEnableAutoCrop =
false;
190 const int LOW_THRESHOLD = 30;
191 const int COLORDIFF = 5;
192 const int GRAYSCALEDIFF = 15;
194 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