| 306 | } |
| 307 | |
| 308 | bool Bitmap::SetPixel(const int x, |
| 309 | const int y, |
| 310 | const BitmapColor<uint8_t>& color) { |
| 311 | if (x < 0 || x >= width_ || y < 0 || y >= height_) { |
| 312 | return false; |
| 313 | } |
| 314 | |
| 315 | if (IsGrey()) { |
| 316 | data_[y * width_ + x] = color.r; |
| 317 | return true; |
| 318 | } else if (IsRGB()) { |
| 319 | uint8_t* pixel = &data_[(y * width_ + x) * channels_]; |
| 320 | pixel[0] = color.r; |
| 321 | pixel[1] = color.g; |
| 322 | pixel[2] = color.b; |
| 323 | return true; |
| 324 | } |
| 325 | |
| 326 | return false; |
| 327 | } |
| 328 | |
| 329 | } // namespace colmap |
no outgoing calls