| 169 | } |
| 170 | |
| 171 | void Userpic::createCache(Image *image) { |
| 172 | const auto size = this->size(); |
| 173 | const auto real = size * style::DevicePixelRatio(); |
| 174 | //_useTransparency |
| 175 | // ? (Images::Option::RoundLarge |
| 176 | // | Images::Option::RoundSkipBottomLeft |
| 177 | // | Images::Option::RoundSkipBottomRight) |
| 178 | // : Images::Option::None; |
| 179 | if (image) { |
| 180 | auto width = image->width(); |
| 181 | auto height = image->height(); |
| 182 | if (width > height) { |
| 183 | width = qMax((width * real) / height, 1); |
| 184 | height = real; |
| 185 | } else { |
| 186 | height = qMax((height * real) / width, 1); |
| 187 | width = real; |
| 188 | } |
| 189 | _userPhoto = image->pixNoCache( |
| 190 | { width, height }, |
| 191 | { |
| 192 | .options = Images::Option::RoundCircle, |
| 193 | .outer = { size, size }, |
| 194 | }); |
| 195 | _userPhoto.setDevicePixelRatio(style::DevicePixelRatio()); |
| 196 | } else { |
| 197 | auto filled = QImage( |
| 198 | QSize(real, real), |
| 199 | QImage::Format_ARGB32_Premultiplied); |
| 200 | filled.setDevicePixelRatio(style::DevicePixelRatio()); |
| 201 | filled.fill(Qt::transparent); |
| 202 | { |
| 203 | auto p = QPainter(&filled); |
| 204 | Ui::EmptyUserpic( |
| 205 | Ui::EmptyUserpic::UserpicColor(_peer->colorIndex()), |
| 206 | _peer->name() |
| 207 | ).paintCircle(p, 0, 0, size, size); |
| 208 | } |
| 209 | //_userPhoto = Images::PixmapFast(Images::Round( |
| 210 | // std::move(filled), |
| 211 | // ImageRoundRadius::Large, |
| 212 | // RectPart::TopLeft | RectPart::TopRight)); |
| 213 | _userPhoto = Images::PixmapFast(std::move(filled)); |
| 214 | } |
| 215 | |
| 216 | _content.update(); |
| 217 | } |
| 218 | |
| 219 | bool Userpic::isGoodPhoto(PhotoData *photo) const { |
| 220 | if (!photo || photo->isNull()) { |
nothing calls this directly
no test coverage detected