| 248 | } |
| 249 | |
| 250 | void setColorInImage( |
| 251 | dec::Targa::Image &image, color_t color, unsigned x, unsigned y, const Header &header) |
| 252 | { |
| 253 | unsigned idx = 0; |
| 254 | |
| 255 | if (header.topToBottom) |
| 256 | idx += y * header.width * 4; |
| 257 | else |
| 258 | idx += (header.height - y - 1) * header.width * 4; |
| 259 | |
| 260 | if (header.leftToRight) |
| 261 | idx += x * 4; |
| 262 | else |
| 263 | idx += (header.width - x - 1) * 4; |
| 264 | |
| 265 | image.data.at(idx) = getr(color); |
| 266 | image.data.at(idx + 1) = getg(color); |
| 267 | image.data.at(idx + 2) = getb(color); |
| 268 | image.data.at(idx + 3) = geta(color); |
| 269 | } |
| 270 | |
| 271 | void readColormap(std::ifstream &file, Header &header) |
| 272 | { |