mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-24 19:02:59 +00:00
handle RGB16 in replaceColors()
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
e166aa922a
commit
46102ae26f
1 changed files with 26 additions and 5 deletions
|
@ -52,11 +52,32 @@ inline static QImage replaceColors(const QImage &source, const QMap<QRgb, QRgb>
|
|||
QImage result(source);
|
||||
const int bpl = result.bytesPerLine();
|
||||
uchar* imagebits = result.bits();
|
||||
for (int h = 0; h < source.height(); h++) {
|
||||
uchar* scan = QFAST_SCAN_LINE(imagebits, bpl, h);
|
||||
for (int w = 0; w < source.width(); w++) {
|
||||
const QRgb pixel = source.pixel(w, h);
|
||||
((uint *)scan)[w] = colormap.value(pixel, pixel);
|
||||
switch (result.format()) {
|
||||
case QImage::Format_RGB32:
|
||||
case QImage::Format_ARGB32:
|
||||
case QImage::Format_ARGB32_Premultiplied: {
|
||||
for (int h = 0; h < source.height(); h++) {
|
||||
uchar* scan = QFAST_SCAN_LINE(imagebits, bpl, h);
|
||||
for (int w = 0; w < source.width(); w++) {
|
||||
const QRgb pixel = source.pixel(w, h);
|
||||
((uint *)scan)[w] = colormap.value(pixel, pixel);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case QImage::Format_RGB16: {
|
||||
for (int h = 0; h < source.height(); h++) {
|
||||
uchar* scan = QFAST_SCAN_LINE(imagebits, bpl, h);
|
||||
for (int w = 0; w < source.width(); w++) {
|
||||
const QRgb pixel = source.pixel(w, h);
|
||||
((quint16 *)scan)[w] = qt_colorConvert<quint16, quint32>(colormap.value(pixel, pixel), 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
Q_ASSERT_X(false, "replaceColors", "internal error");
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
|
Loading…
Add table
Reference in a new issue