77 if (this->width == 0 || this->height == 0)
78 throw std::logic_error{
"Unexpected dimensions (" +
79 imagePropertiesString(*
this) +
')'};
81 decltype(pixels.size()) expected{};
83 case Colorspace::Grayscale:
85 case BitsPerChannel::Sixteen:
87 case BitsPerPixel::Sixteen:
90 case BitsPerPixel::Eight:
92 case BitsPerPixel::TwentyFour:
94 case BitsPerPixel::FortyEight:
95 throw std::logic_error{
"Unexpected "
97 imagePropertiesString(*
this) +
')'};
100 expected = width * height * 2ul;
101 if (pixels.size() != expected)
102 throw std::logic_error{
"Unexpected pixel "
103 "length (expected = " +
104 std::to_string(expected) +
", actual = " +
105 std::to_string(pixels.size()) +
')'};
108 case BitsPerChannel::Eight:
110 case BitsPerPixel::Eight:
113 case BitsPerPixel::Sixteen:
115 case BitsPerPixel::TwentyFour:
117 case BitsPerPixel::FortyEight:
118 throw std::logic_error{
"Unexpected "
120 imagePropertiesString(*
this) +
')'};
123 expected = width * height;
124 if (pixels.size() != expected)
125 throw std::logic_error{
"Unexpected pixel "
126 "length (expected = " +
127 std::to_string(expected) +
", actual = " +
128 std::to_string(this->pixels.size()) +
')'};
134 case Colorspace::RGB:
136 case BitsPerChannel::Sixteen:
138 case BitsPerPixel::FortyEight:
141 case BitsPerPixel::Eight:
143 case BitsPerPixel::Sixteen:
145 case BitsPerPixel::TwentyFour:
146 throw std::logic_error{
"Unexpected "
148 imagePropertiesString(*
this) +
')'};
151 expected = width * height * (3ul * 2ul);
152 if (pixels.size() != expected)
153 throw std::logic_error{
"Unexpected pixel "
154 "length (expected = " +
155 std::to_string(expected) +
", actual = " +
156 std::to_string(this->pixels.size()) +
')'};
159 case BitsPerChannel::Eight:
161 case BitsPerPixel::TwentyFour:
164 case BitsPerPixel::Eight:
166 case BitsPerPixel::Sixteen:
168 case BitsPerPixel::FortyEight:
169 throw std::logic_error{
"Unexpected "
171 imagePropertiesString(*
this) +
')'};
174 expected = width * height * 3ul;
175 if (pixels.size() != expected)
176 throw std::logic_error{
"Unexpected pixel "
177 "length (expected = " +
178 std::to_string(expected) +
", actual = " +
179 std::to_string(this->pixels.size()) +
')'};
186 throw std::logic_error{
"Untested "
187 "combination (" + imagePropertiesString(*
this) +
')'};