Lines 255-271
public:
Link Here
|
255 |
if (!constantAlpha) { |
255 |
if (!constantAlpha) { |
256 |
const qreal spacing = qreal(0.02); |
256 |
const qreal spacing = qreal(0.02); |
257 |
QGradientStops newStops; |
257 |
QGradientStops newStops; |
258 |
QRgb fromColor = PREMUL(stops.at(0).second.rgba()); |
258 |
QRgb fromColor = qPremultiply(stops.at(0).second.rgba()); |
259 |
QRgb toColor; |
259 |
QRgb toColor; |
260 |
for (int i = 0; i + 1 < stops.size(); ++i) { |
260 |
for (int i = 0; i + 1 < stops.size(); ++i) { |
261 |
int parts = qCeil((stops.at(i + 1).first - stops.at(i).first) / spacing); |
261 |
int parts = qCeil((stops.at(i + 1).first - stops.at(i).first) / spacing); |
262 |
newStops.append(stops.at(i)); |
262 |
newStops.append(stops.at(i)); |
263 |
toColor = PREMUL(stops.at(i + 1).second.rgba()); |
263 |
toColor = qPremultiply(stops.at(i + 1).second.rgba()); |
264 |
|
264 |
|
265 |
if (parts > 1) { |
265 |
if (parts > 1) { |
266 |
qreal step = (stops.at(i + 1).first - stops.at(i).first) / parts; |
266 |
qreal step = (stops.at(i + 1).first - stops.at(i).first) / parts; |
267 |
for (int j = 1; j < parts; ++j) { |
267 |
for (int j = 1; j < parts; ++j) { |
268 |
QRgb color = INV_PREMUL(INTERPOLATE_PIXEL_256(fromColor, 256 - 256 * j / parts, toColor, 256 * j / parts)); |
268 |
QRgb color = qUnpremultiply(INTERPOLATE_PIXEL_256(fromColor, 256 - 256 * j / parts, toColor, 256 * j / parts)); |
269 |
newStops.append(QGradientStop(stops.at(i).first + j * step, QColor::fromRgba(color))); |
269 |
newStops.append(QGradientStop(stops.at(i).first + j * step, QColor::fromRgba(color))); |
270 |
} |
270 |
} |
271 |
} |
271 |
} |