const QPixmap &AnimatedGif::current(int32 width, int32 height, bool rounded) { if (!width) width = w; if (!height) height = h; if ((frames[frame].isNull() || frames[frame].width() != width || frames[frame].height() != height) && !images[frame].isNull()) { QImage img = images[frame]; if (img.width() != width || img.height() != height) img = img.scaled(width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); if (rounded) imageRound(img); frames[frame] = QPixmap::fromImage(img, Qt::ColorOnly); frames[frame].setDevicePixelRatio(cRetinaFactor()); } return frames[frame]; }
void BackgroundRow::updateImage() { int32 size = st::settingsBackgroundSize * cIntRetinaFactor(); QImage back(size, size, QImage::Format_ARGB32_Premultiplied); back.setDevicePixelRatio(cRetinaFactor()); { QPainter p(&back); auto &pix = Window::chatBackground()->image(); int sx = (pix.width() > pix.height()) ? ((pix.width() - pix.height()) / 2) : 0; int sy = (pix.height() > pix.width()) ? ((pix.height() - pix.width()) / 2) : 0; int s = (pix.width() > pix.height()) ? pix.height() : pix.width(); p.setRenderHint(QPainter::SmoothPixmapTransform); p.drawPixmap(0, 0, st::settingsBackgroundSize, st::settingsBackgroundSize, pix, sx, sy, s, s); } imageRound(back, ImageRoundRadius::Small); _background = App::pixmapFromImageInPlace(std_::move(back)); _background.setDevicePixelRatio(cRetinaFactor()); rtlupdate(radialRect()); if (radialLoading()) { radialStart(); } }