| 242 | } |
| 243 | |
| 244 | void NetHackQtGlyphs::setSize(int w, int h) |
| 245 | { |
| 246 | if (size == QSize(w, h)) |
| 247 | return; |
| 248 | size = QSize(w, h); |
| 249 | if (!w || !h) |
| 250 | return; // Still not decided |
| 251 | |
| 252 | if (size == pm1.size()) { // not zoomed |
| 253 | pm = pm1; |
| 254 | return; |
| 255 | } |
| 256 | if (size == pm2.size()) { // zoomed |
| 257 | pm = pm2; |
| 258 | return; |
| 259 | } |
| 260 | |
| 261 | bool was1 = (size == pm1.size()); |
| 262 | if (w == tilefile_tile_W && h == tilefile_tile_H) { |
| 263 | pm.convertFromImage(img); |
| 264 | } else { |
| 265 | QApplication::setOverrideCursor(Qt::WaitCursor); |
| 266 | QImage scaled = img.scaled( |
| 267 | w * img.width() / tilefile_tile_W, |
| 268 | h * img.height() / tilefile_tile_H, |
| 269 | Qt::IgnoreAspectRatio, |
| 270 | Qt::FastTransformation |
| 271 | ); |
| 272 | pm.convertFromImage(scaled, Qt::ThresholdDither | Qt::PreferDither); |
| 273 | QApplication::restoreOverrideCursor(); |
| 274 | } |
| 275 | (was1 ? pm2 : pm1) = pm; |
| 276 | } |
| 277 | |
| 278 | } // namespace nethack_qt_ |
no test coverage detected