126 friend class Rgb32ConstPixel;
129 typedef Rgb32 FormatType;
130 typedef Color ColorType;
133 template <
typename T>
134 Rgb32Pixel(T& view, Pt::ssize_t x, Pt::ssize_t y);
136 Rgb32Pixel(
const Rgb32Pixel& p) =
default;
138 ~Rgb32Pixel() =
default;
140 Rgb32Pixel& operator=(
const Rgb32Pixel&) =
delete;
146 template <
typename T>
147 void reset(T& view, Pt::ssize_t x, Pt::ssize_t y);
149 void reset(
const Rgb32Pixel& p);
188 void advance(Pt::ssize_t n);
190 void advanceLines(Pt::ssize_t n);
192 void assign(
const Rgb32Pixel& p);
194 void assign(
const Rgb32ConstPixel& p);
196 void assign(
const Rgb32Pixel& p, std::size_t length);
198 void assign(
const Rgb32ConstPixel& p, std::size_t length);
200 void assign(
const Color* colors, std::size_t length);
202 void assign(
const Rgb32Color* colors, std::size_t length);
204 void getColors(
Color* colors, std::size_t length)
const;
214 bool equals(
const Rgb32Pixel& p)
const;
216 bool equals(
const Rgb32ConstPixel& p)
const;
227 friend class Rgb32Pixel;
230 typedef Rgb32 FormatType;
231 typedef Color ColorType;
235 Pt::ssize_t x, Pt::ssize_t y);
238 template <
typename T>
239 Rgb32ConstPixel(
const T& view, Pt::ssize_t x, Pt::ssize_t y);
241 template <
typename T>
242 Rgb32ConstPixel(T& view, Pt::ssize_t x, Pt::ssize_t y);
244 Rgb32ConstPixel(
const Rgb32ConstPixel& p) =
default;
246 Rgb32ConstPixel(
const Rgb32Pixel& p);
248 ~Rgb32ConstPixel() =
default;
250 Rgb32ConstPixel& operator=(
const Rgb32ConstPixel&) =
delete;
252 template <
typename T>
253 void reset(
const T& view, Pt::ssize_t x, Pt::ssize_t y);
255 template <
typename T>
256 void reset(T& view, Pt::ssize_t x, Pt::ssize_t y);
258 void reset(
const Rgb32ConstPixel& p);
260 void reset(
const Rgb32Pixel& p);
288 void advance(Pt::ssize_t n);
290 void advanceLines(Pt::ssize_t n);
292 void getColors(
Color* colors, std::size_t length)
const;
298 bool equals(
const Rgb32ConstPixel& p)
const;
300 bool equals(
const Rgb32Pixel& p)
const;
314class PT_GFX_API Rgb32 final :
public ImageFormat
316 static const unsigned PixelWidth = 4;
323 static const Rgb32& get()
331 : ImageFormat(PixelWidth)
341 std::size_t imageSize(std::size_t width, std::size_t height,
342 std::size_t padding)
const
344 std::size_t stride = (width * 4) + padding;
345 std::size_t n = stride * height;
350 virtual std::unique_ptr<ImageFormat> onClone()
const override
352 return std::unique_ptr<ImageFormat>(
new Rgb32);
355 virtual const std::type_info& onGetType()
const override
357 return typeid(*this);
360 virtual std::size_t onImageSize(Pt::ssize_t width, Pt::ssize_t height,
361 std::size_t padding)
const override;
363 virtual PixelBase* onCreatePixel(
Pt::uint8_t* data,
const ViewBase& view,
364 Pt::ssize_t x, Pt::ssize_t y,
365 PixelStorage& store)
const override;
368 template <
typename BasePtr>
369 static BasePtr getPixel(
const ViewBase& view, BasePtr base,
370 Pt::ssize_t xpos, Pt::ssize_t ypos)
372 base += ypos * view.stride();
373 base += xpos * PixelWidth;
377 template <
typename BasePtr>
378 static BasePtr advance(
const ViewBase& view, BasePtr base)
380 return base + PixelWidth;
383 template <
typename BasePtr>
384 static BasePtr advance(
const ViewBase& view, BasePtr base, Pt::ssize_t n)
386 return base + n * PixelWidth;
389 template <
typename BasePtr>
390 static BasePtr skipPadding(
const ViewBase& view, BasePtr base)
392 Pt::ssize_t w = view.width() * PixelWidth;
393 Pt::ssize_t off = view.stride() - w;
397 template <
typename BasePtr>
398 static BasePtr advanceLines(
const ViewBase& view, BasePtr base, Pt::ssize_t n)
400 return base + n * view.stride();
403 static Rgb32Color getRgb32Color(
const Pt::uint8_t* p);
409 static void getColors(
const Pt::uint8_t* p, Rgb32Color* colors, std::size_t n);
411 static void getColors(
const Pt::uint8_t* p, Color* colors, std::size_t n);
413 static void getColors(
const Pt::uint8_t* p, Gfx::ColorF* colors, std::size_t n);
415 static void assign(
Pt::uint8_t* to,
const Color& from);
417 static void assign(
Pt::uint8_t* to,
const ColorF& c);
419 static void fill(
Pt::uint8_t* to, std::size_t length,
const Rgb32Color& c);
421 static void fill(
Pt::uint8_t* to, std::size_t length,
const Color& c);
423 static void fill(
Pt::uint8_t* to, std::size_t length,
const ColorF& c);
425 static void assign(
Pt::uint8_t* to,
const Rgb32Color* colors, std::size_t length);
427 static void assign(
Pt::uint8_t* to,
const Color* colors, std::size_t length);
429 static void assign(
Pt::uint8_t* to,
const ColorF* colors, std::size_t length);
455 const float a = c.alpha();
458 const Pt::uint32_t g = ColorF::toChannel8(c.green() * a);
459 const Pt::uint32_t b = ColorF::toChannel8(c.blue() * a);
461 return (au << 24) | (r << 16) | (g << 8) | b;