| 598 | } |
| 599 | |
| 600 | double Bitmap::Thumbnail(const int max_image_size, RescaleFilter filter) { |
| 601 | THROW_CHECK_GT(max_image_size, 0); |
| 602 | if (width_ <= max_image_size && height_ <= max_image_size) { |
| 603 | return 1.0; |
| 604 | } |
| 605 | // Fit the down-sampled version exactly into the max dimensions. |
| 606 | const double scale = |
| 607 | static_cast<double>(max_image_size) / std::max(width_, height_); |
| 608 | Rescale(static_cast<int>(std::round(width_ * scale)), |
| 609 | static_cast<int>(std::round(height_ * scale)), |
| 610 | filter); |
| 611 | return scale; |
| 612 | } |
| 613 | |
| 614 | void Bitmap::Rot90(int k) { |
| 615 | if (IsEmpty()) { |