102 friend class Rgb16ConstPixel;
105 typedef Rgb16 FormatType;
106 typedef Color ColorType;
109 template <
typename T>
110 Rgb16Pixel(T& view, Pt::ssize_t x, Pt::ssize_t y);
112 Rgb16Pixel(
const Rgb16Pixel& p) =
default;
114 ~Rgb16Pixel() =
default;
116 Rgb16Pixel& operator=(
const Rgb16Pixel&) =
delete;
122 template <
typename T>
123 void reset(T& view, Pt::ssize_t x, Pt::ssize_t y);
125 void reset(
const Rgb16Pixel& p);
142 Color getColor()
const;
152 void advance(Pt::ssize_t n);
154 void advanceLines(Pt::ssize_t n);
156 void assign(
const Rgb16Pixel& p);
158 void assign(
const Rgb16ConstPixel& p);
160 void assign(
const Rgb16Pixel& p, std::size_t length);
162 void assign(
const Rgb16ConstPixel& p, std::size_t length);
164 void getColors(
Color* colors, std::size_t length)
const;
170 void assign(
const Color* colors, std::size_t length);
172 void assign(
const Rgb16Color* colors, std::size_t length);
178 bool equals(
const Rgb16Pixel& p)
const;
180 bool equals(
const Rgb16ConstPixel& p)
const;
191 friend class Rgb16Pixel;
194 typedef Rgb16 FormatType;
195 typedef Color ColorType;
199 Pt::ssize_t x, Pt::ssize_t y);
202 template <
typename T>
203 Rgb16ConstPixel(
const T& view, Pt::ssize_t x, Pt::ssize_t y);
205 template <
typename T>
206 Rgb16ConstPixel(T& view, Pt::ssize_t x, Pt::ssize_t y);
208 Rgb16ConstPixel(
const Rgb16ConstPixel& p) =
default;
210 Rgb16ConstPixel(
const Rgb16Pixel& p);
212 ~Rgb16ConstPixel() =
default;
214 Rgb16ConstPixel& operator=(
const Rgb16ConstPixel&) =
delete;
216 template <
typename T>
217 void reset(
const T& view, Pt::ssize_t x, Pt::ssize_t y);
219 template <
typename T>
220 void reset(T& view, Pt::ssize_t x, Pt::ssize_t y);
222 void reset(
const Rgb16ConstPixel& p);
224 void reset(
const Rgb16Pixel& p);
238 Color getColor()
const;
248 void advance(Pt::ssize_t n);
250 void advanceLines(Pt::ssize_t n);
252 void getColors(
Color* colors, std::size_t length)
const;
258 bool equals(
const Rgb16ConstPixel& p)
const;
260 bool equals(
const Rgb16Pixel& p)
const;
269class PT_GFX_API Rgb16 final :
public ImageFormat
271 static const unsigned PixelWidth = 2;
278 static const Rgb16& get()
286 : ImageFormat(PixelWidth)
296 std::size_t imageSize(std::size_t width, std::size_t height,
297 std::size_t padding)
const
299 std::size_t stride = (width * PixelWidth) + padding;
300 std::size_t n = stride * height;
305 virtual std::unique_ptr<ImageFormat> onClone()
const override
307 return std::unique_ptr<ImageFormat>(
new Rgb16);
310 virtual const std::type_info& onGetType()
const override
312 return typeid(*this);
315 virtual std::size_t onImageSize(Pt::ssize_t width, Pt::ssize_t height,
316 std::size_t padding)
const override;
318 virtual PixelBase* onCreatePixel(
Pt::uint8_t* data,
const ViewBase& view,
319 Pt::ssize_t x, Pt::ssize_t y,
320 PixelStorage& store)
const override;
323 template <
typename BasePtr>
324 static BasePtr getPixel(
const ViewBase& view, BasePtr base,
325 Pt::ssize_t xpos, Pt::ssize_t ypos)
327 base += ypos * view.stride();
328 base += xpos * PixelWidth;
332 template <
typename BasePtr>
333 static BasePtr advance(
const ViewBase& view, BasePtr base)
335 return base + PixelWidth;
338 template <
typename BasePtr>
339 static BasePtr advance(
const ViewBase& view, BasePtr base, Pt::ssize_t n)
341 return base + n * PixelWidth;
344 template <
typename BasePtr>
345 static BasePtr skipPadding(
const ViewBase& view, BasePtr base)
347 Pt::ssize_t w = view.width() * PixelWidth;
348 Pt::ssize_t off = view.stride() - w;
352 template <
typename BasePtr>
353 static BasePtr advanceLines(
const ViewBase& view, BasePtr base, Pt::ssize_t n)
355 return base + n * view.stride();
362 static Rgb16Color getRgb16Color(
const Pt::uint8_t* p);
364 static void getColors(
const Pt::uint8_t* p, Gfx::ColorF* colors, std::size_t n);
366 static void getColors(
const Pt::uint8_t* p, Color* colors, std::size_t n);
368 static void getColors(
const Pt::uint8_t* p, Rgb16Color* colors, std::size_t n);
370 static void assign(
Pt::uint8_t* to,
const Color& from);
372 static void assign(
Pt::uint8_t* to,
const ColorF& c);
374 static void assign(
Pt::uint8_t* to,
const Rgb16Color& c);
376 static void fill(
Pt::uint8_t* to, std::size_t length,
const Color& c);
378 static void fill(
Pt::uint8_t* to, std::size_t length,
const ColorF& c);
380 static void fill(
Pt::uint8_t* to, std::size_t length,
const Rgb16Color& c);
382 static void assign(
Pt::uint8_t* to,
const Color* colors, std::size_t length);
384 static void assign(
Pt::uint8_t* to,
const ColorF* colors, std::size_t length);
386 static void assign(
Pt::uint8_t* to,
const Rgb16Color* colors, std::size_t length);