| 89 | } |
| 90 | |
| 91 | bool Save(GSPng::Format fmt, const std::string& file, const u8* image, int w, int h, int pitch, int compression, bool rb_swapped) |
| 92 | { |
| 93 | std::string root = file; |
| 94 | root.replace(file.length() - 4, 4, ""); |
| 95 | |
| 96 | pxAssert(fmt >= Format::START && fmt < Format::COUNT); |
| 97 | |
| 98 | if (compression < 0 || compression > Z_BEST_COMPRESSION) |
| 99 | compression = Z_BEST_SPEED; |
| 100 | |
| 101 | std::unique_ptr<u8[]> row(new u8[pixel[fmt].bytes_per_pixel_out * w]); |
| 102 | |
| 103 | std::string filename = root + pixel[fmt].extension[0]; |
| 104 | if (!SaveFile(filename, fmt, image, row.get(), w, h, pitch, compression, rb_swapped, true)) |
| 105 | return false; |
| 106 | |
| 107 | // Second image |
| 108 | if (pixel[fmt].extension[1] == nullptr) |
| 109 | return true; |
| 110 | |
| 111 | filename = root + pixel[fmt].extension[1]; |
| 112 | return SaveFile(filename, fmt, image, row.get(), w, h, pitch, compression); |
| 113 | } |
| 114 | |
| 115 | Transaction::Transaction(GSPng::Format fmt, const std::string& file, const u8* image, int w, int h, int pitch, int compression) |
| 116 | : m_fmt(fmt), m_file(file), m_w(w), m_h(h), m_pitch(pitch), m_compression(compression) |
no test coverage detected