mirror of https://github.com/procxx/kepka.git
Improve emoji quality while creating cache.
This commit is contained in:
parent
3e7a688811
commit
c4d919d46b
|
@ -297,7 +297,8 @@ std::vector<QImage> LoadSprites(int id) {
|
||||||
) | ranges::view::transform([&](int index) {
|
) | ranges::view::transform([&](int index) {
|
||||||
return base + QString::number(index + 1) + ".webp";
|
return base + QString::number(index + 1) + ".webp";
|
||||||
}) | ranges::view::transform([](const QString &path) {
|
}) | ranges::view::transform([](const QString &path) {
|
||||||
return QImage(path, "WEBP");
|
return QImage(path, "WEBP").convertToFormat(
|
||||||
|
QImage::Format_ARGB32_Premultiplied);
|
||||||
}) | ranges::to_vector;
|
}) | ranges::to_vector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -383,14 +384,26 @@ void UniversalImages::draw(
|
||||||
int y) const {
|
int y) const {
|
||||||
Expects(emoji->sprite() < _sprites.size());
|
Expects(emoji->sprite() < _sprites.size());
|
||||||
|
|
||||||
const auto factored = (size / p.device()->devicePixelRatio());
|
|
||||||
const auto large = kUniversalSize;
|
const auto large = kUniversalSize;
|
||||||
|
const auto &original = _sprites[emoji->sprite()];
|
||||||
PainterHighQualityEnabler hq(p);
|
const auto data = original.bits();
|
||||||
p.drawImage(
|
const auto stride = original.bytesPerLine();
|
||||||
QRect(x, y, factored, factored),
|
const auto format = original.format();
|
||||||
_sprites[emoji->sprite()],
|
const auto row = emoji->row();
|
||||||
QRect(emoji->column() * large, emoji->row() * large, large, large));
|
const auto column = emoji->column();
|
||||||
|
auto single = QImage(
|
||||||
|
data + (row * kImagesPerRow * large + column) * large * 4,
|
||||||
|
large,
|
||||||
|
large,
|
||||||
|
stride,
|
||||||
|
format
|
||||||
|
).scaled(
|
||||||
|
size,
|
||||||
|
size,
|
||||||
|
Qt::IgnoreAspectRatio,
|
||||||
|
Qt::SmoothTransformation);
|
||||||
|
single.setDevicePixelRatio(p.device()->devicePixelRatio());
|
||||||
|
p.drawImage(x, y, single);
|
||||||
}
|
}
|
||||||
|
|
||||||
QImage UniversalImages::generate(int size, int index) const {
|
QImage UniversalImages::generate(int size, int index) const {
|
||||||
|
@ -410,7 +423,6 @@ QImage UniversalImages::generate(int size, int index) const {
|
||||||
result.fill(Qt::transparent);
|
result.fill(Qt::transparent);
|
||||||
{
|
{
|
||||||
QPainter p(&result);
|
QPainter p(&result);
|
||||||
PainterHighQualityEnabler hq(p);
|
|
||||||
for (auto y = 0; y != rows; ++y) {
|
for (auto y = 0; y != rows; ++y) {
|
||||||
for (auto x = 0; x != kImagesPerRow; ++x) {
|
for (auto x = 0; x != kImagesPerRow; ++x) {
|
||||||
const auto single = QImage(
|
const auto single = QImage(
|
||||||
|
|
Loading…
Reference in New Issue