* Loads the contents of an X-Com SCR image file into * the surface. SCR files are simply uncompressed images * containing the palette offset of each pixel. * @param filename Filename of the SCR image. * @sa http://www.ufopaedia.org/index.php?title=Image_Formats#SCR_.26_DAT */
| 218 | * @sa http://www.ufopaedia.org/index.php?title=Image_Formats#SCR_.26_DAT |
| 219 | */ |
| 220 | void Surface::loadScr(const std::string &filename) |
| 221 | { |
| 222 | // Load file and put pixels in surface |
| 223 | std::ifstream imgFile(filename.c_str(), std::ios::binary); |
| 224 | if (!imgFile) |
| 225 | { |
| 226 | throw Exception(filename + " not found"); |
| 227 | } |
| 228 | |
| 229 | std::vector<char> buffer((std::istreambuf_iterator<char>(imgFile)), (std::istreambuf_iterator<char>())); |
| 230 | |
| 231 | // Lock the surface |
| 232 | lock(); |
| 233 | |
| 234 | int x = 0, y = 0; |
| 235 | |
| 236 | for (std::vector<char>::iterator i = buffer.begin(); i != buffer.end(); ++i) |
| 237 | { |
| 238 | setPixelIterative(&x, &y, *i); |
| 239 | } |
| 240 | |
| 241 | // Unlock the surface |
| 242 | unlock(); |
| 243 | } |
| 244 | |
| 245 | /** |
| 246 | * Loads the contents of an image file of a |
no test coverage detected