mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-01-25 08:44:38 +00:00
Fix color conversion for Qt 5.12.5.
This commit is contained in:
parent
e952c513d5
commit
3ae7f9f93d
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user