Fix color conversion for Qt 5.12.5.

This commit is contained in:
John Preston 2019-10-20 13:00:36 +04:00
parent e952c513d5
commit 3ae7f9f93d

View File

@ -48,55 +48,37 @@ void AlignedImageBufferCleanupHandler(void* data) {
} }
void UnPremultiplyLine(uchar *dst, const uchar *src, int intsCount) { void UnPremultiplyLine(uchar *dst, const uchar *src, int intsCount) {
#ifndef TDESKTOP_OFFICIAL_TARGET // #TODO 5.12.5 [[maybe_unused]] const auto udst = reinterpret_cast<uint*>(dst);
const auto layout = &qPixelLayouts[QImage::Format_ARGB32]; const auto usrc = reinterpret_cast<const uint*>(src);
const auto convert = layout->convertFromARGB32PM;
#else // TDESKTOP_OFFICIAL_TARGET
const auto layout = nullptr;
const auto convert = [](
uint *dst,
const uint *src,
int count,
std::nullptr_t,
std::nullptr_t) {
for (auto i = 0; i != count; ++i) {
dst[i] = qUnpremultiply(src[i]);
}
};
#endif // TDESKTOP_OFFICIAL_TARGET
convert( #ifndef TDESKTOP_OFFICIAL_TARGET
reinterpret_cast<uint*>(dst), for (auto i = 0; i != intsCount; ++i) {
reinterpret_cast<const uint*>(src), udst[i] = qUnpremultiply(usrc[i]);
intsCount, }
layout, #elif QT_VERSION < QT_VERSION_CHECK(5, 12, 0)
nullptr); static const auto layout = &qPixelLayouts[QImage::Format_ARGB32];
layout->convertFromARGB32PM(udst, usrc, intsCount, layout, nullptr);
#else // Qt >= 5.12
static const auto layout = &qPixelLayouts[QImage::Format_ARGB32];
layout->storeFromARGB32PM(dst, usrc, 0, intsCount, nullptr, nullptr);
#endif // Qt >= 5.12
} }
void PremultiplyLine(uchar *dst, const uchar *src, int intsCount) { void PremultiplyLine(uchar *dst, const uchar *src, int intsCount) {
#ifndef TDESKTOP_OFFICIAL_TARGET // #TODO 5.12.5 const auto udst = reinterpret_cast<uint*>(dst);
const auto layout = &qPixelLayouts[QImage::Format_ARGB32]; [[maybe_unused]] const auto usrc = reinterpret_cast<const uint*>(src);
const auto convert = layout->convertToARGB32PM;
#else // TDESKTOP_OFFICIAL_TARGET
const auto layout = nullptr;
const auto convert = [](
uint *dst,
const uint *src,
int count,
std::nullptr_t,
std::nullptr_t) {
for (auto i = 0; i != count; ++i) {
dst[i] = qPremultiply(src[i]);
}
};
#endif // TDESKTOP_OFFICIAL_TARGET
convert( #ifndef TDESKTOP_OFFICIAL_TARGET
reinterpret_cast<uint*>(dst), for (auto i = 0; i != count; ++i) {
reinterpret_cast<const uint*>(src), dst[i] = qPremultiply(src[i]);
intsCount, }
layout, #elif QT_VERSION < QT_VERSION_CHECK(5, 12, 0)
nullptr); static const auto layout = &qPixelLayouts[QImage::Format_ARGB32];
layout->convertToARGB32PM(udst, usrc, intsCount, layout, nullptr);
#else // Qt >= 5.12
static const auto layout = &qPixelLayouts[QImage::Format_ARGB32];
layout->fetchToARGB32PM(udst, src, 0, intsCount, nullptr, nullptr);
#endif // Qt >= 5.12
} }
} // namespace } // namespace