| 316 | } |
| 317 | |
| 318 | void Image::set(Vec2U const& pos, Vec4B const& c) { |
| 319 | if (pos[0] >= m_width || pos[1] >= m_height) { |
| 320 | throw ImageException(strf("{} out of range in Image::set", pos)); |
| 321 | } else if (bytesPerPixel() == 4) { |
| 322 | size_t offset = pos[1] * m_width * 4 + pos[0] * 4; |
| 323 | m_data[offset] = c[0]; |
| 324 | m_data[offset + 1] = c[1]; |
| 325 | m_data[offset + 2] = c[2]; |
| 326 | m_data[offset + 3] = c[3]; |
| 327 | } else if (bytesPerPixel() == 3) { |
| 328 | size_t offset = pos[1] * m_width * 3 + pos[0] * 3; |
| 329 | m_data[offset] = c[0]; |
| 330 | m_data[offset + 1] = c[1]; |
| 331 | m_data[offset + 2] = c[2]; |
| 332 | } |
| 333 | } |
| 334 | |
| 335 | void Image::set(Vec2U const& pos, Vec3B const& c) { |
| 336 | if (pos[0] >= m_width || pos[1] >= m_height) { |
no test coverage detected