Files
piphoto/color.h

25 lines
573 B
C
Raw Normal View History

2017-08-06 19:12:44 +00:00
#pragma once
2017-08-10 13:51:39 -07:00
#include <array>
2017-08-06 19:39:11 +00:00
#include <cstdint>
2017-08-07 06:15:20 +00:00
#include <iostream>
2017-08-06 19:39:11 +00:00
2017-08-10 13:51:39 -07:00
#include "intmath.h"
2017-08-07 04:32:01 +00:00
2017-08-10 13:51:39 -07:00
constexpr uint32_t kNumColors = UINT16_MAX;
2017-08-06 19:12:44 +00:00
2017-08-10 13:51:39 -07:00
// 32-bit for compiler convenience, but values are 16-bit
struct Color : public std::array<uint32_t, 3> {
2017-08-06 19:12:44 +00:00
constexpr uint32_t Difference(const Color& other) const;
};
constexpr uint32_t Color::Difference(const Color& other) const {
return (
2017-08-10 13:51:39 -07:00
AbsDiff(this->at(0), other.at(0)) +
AbsDiff(this->at(1), other.at(1)) +
AbsDiff(this->at(2), other.at(2))
2017-08-06 19:12:44 +00:00
);
}
2017-08-07 06:15:20 +00:00
std::ostream& operator<<(std::ostream& os, const Color& color);