1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825
|
/*
* Simd Library (http://ermig1979.github.io/Simd).
*
* Copyright (c) 2011-2021 Yermalayeu Ihar.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef __SimdPixel_hpp__
#define __SimdPixel_hpp__
#include "Simd/SimdView.hpp"
namespace Simd
{
/*! @ingroup cpp_pixels
\short Contains various pixel structures.
Contains various pixel structures useful for work with Simd::View structure.
*/
namespace Pixel
{
struct Bgr24;
struct Bgra32;
struct Hsv24;
struct Hsl24;
struct Rgb24;
struct Rgba32;
//-------------------------------------------------------------------------
/*! @ingroup cpp_pixels
\short 24-bit BGR pixel.
Provides manipulation of 24-bit BGR (Blue, Green, Red) pixels of the View struct.
*/
struct Bgr24
{
uint8_t blue; /*!< \brief 8-bit blue channel 24-bit BGR pixel. */
uint8_t green; /*!< \brief 8-bit green channel 24-bit BGR pixel. */
uint8_t red; /*!< \brief 8-bit red channel 24-bit BGR pixel. */
/*!
Creates a new 24-bit BGR pixel structure with specified channel values.
\param [in] gray - initial value for all channels. It is equal to 0 by default.
*/
Bgr24(const uint8_t & gray = uint8_t(0));
/*!
Creates a new 24-bit BGR pixel structure with specified channel values.
\param [in] b - initial value for blue channel.
\param [in] g - initial value for green channel.
\param [in] r - initial value for red channel.
*/
Bgr24(const uint8_t & b, const uint8_t & g, const uint8_t & r);
/*!
Creates a new 24-bit BGR pixel structure on the base of 32-bit BGRA pixel.
\param [in] p - 32-bit BGRA pixel.
*/
Bgr24(const Bgra32 & p);
/*!
Creates a new 24-bit BGR pixel structure on the base of 24-bit RGB pixel.
\param [in] p - 24-bit RGB pixel.
*/
Bgr24(const Rgb24 & p);
/*!
Creates a new 24-bit BGR pixel structure on the base of 32-bit RGBA pixel.
\param [in] p - 32-bit RGBA pixel.
*/
Bgr24(const Rgba32& p);
/*!
Creates a copy of 24-bit BGR pixel structure.
\param [in] p - 24-bit BGR pixel.
*/
Bgr24(const Bgr24 & p);
/*!
\fn template <template<class> class A> static const Bgr24 & At(const View<A> & view, ptrdiff_t col, ptrdiff_t row);
Gets constant reference to the pixel with specific coordinates at the image view.
\param [in] view - an image view of 24-bit BGR pixel format.
\param [in] col - x-coordinate of the pixel.
\param [in] row - y-coordinate of the pixel.
\return a constant reference to the pixel.
*/
template <template<class> class A> static const Bgr24 & At(const View<A> & view, ptrdiff_t col, ptrdiff_t row);
/*!
\fn template <template<class> class A> static Bgr24 & At(View<A> & view, ptrdiff_t col, ptrdiff_t row);
Gets reference to the pixel with specific coordinates at the image view.
\param [in] view - an image view of 24-bit BGR pixel format.
\param [in] col - x-coordinate of the pixel.
\param [in] row - y-coordinate of the pixel.
\return a reference to the pixel.
*/
template <template<class> class A> static Bgr24 & At(View<A> & view, ptrdiff_t col, ptrdiff_t row);
};
/*! @ingroup cpp_pixels
\short 32-bit BGRA pixel.
Provides manipulation of 32-bit BGRA (Blue, Green, Red, Alpha) pixels of the View struct.
*/
struct Bgra32
{
uint8_t blue; /*!< \brief 8-bit blue channel 32-bit BGRA pixel. */
uint8_t green; /*!< \brief 8-bit green channel 32-bit BGRA pixel. */
uint8_t red; /*!< \brief 8-bit red channel 32-bit BGRA pixel. */
uint8_t alpha; /*!< \brief 8-bit alpha channel 32-bit BGRA pixel. */
/*!
Creates a new 32-bit BGRA pixel structure with specified channel values.
\param [in] gray - initial value for blue, green and red channels. It is equal to 0 by default.
\param [in] a - initial value for alpha channel. It is equal to 255 by default.
*/
Bgra32(const uint8_t & gray = uint8_t(0), const uint8_t & a = uint8_t(255));
/*!
Creates a new 32-bit BGRA pixel structure with specified channel values.
\param [in] b - initial value for blue channel.
\param [in] g - initial value for green channel.
\param [in] r - initial value for red channel.
\param [in] a - initial value for alpha channel. It is equal to 255 by default.
*/
Bgra32(const uint8_t & b, const uint8_t & g, const uint8_t & r, const uint8_t & a = uint8_t(255));
/*!
Creates a new 32-bit BGRA pixel structure on the base of 24-bit BGR pixel.
\param [in] p - 24-bit BGR pixel.
\param [in] a - initial value for alpha channel. It is equal to 255 by default.
*/
Bgra32(const Bgr24 & p, const uint8_t & a = uint8_t(255));
/*!
Creates a new 32-bit BGRA pixel structure on the base of 24-bit RGB pixel.
\param [in] p - 24-bit RGB pixel.
\param [in] a - initial value for alpha channel. It is equal to 255 by default.
*/
Bgra32(const Rgb24 & p, const uint8_t & a = uint8_t(255));
/*!
Creates a new 32-bit BGRA pixel structure on the base of 32-bit RGBA pixel.
\param [in] p - 32-bit RGBA pixel.
*/
Bgra32(const Rgba32& p);
/*!
Creates a copy of 32-bit BGRA pixel structure.
\param [in] p - 32-bit BGRA pixel.
*/
Bgra32(const Bgra32 & p);
/*!
\fn template <template<class> class A> static const Bgr32 & At(const View<A> & view, ptrdiff_t col, ptrdiff_t row);
Gets constant reference to the pixel with specific coordinates at the image view.
\param [in] view - an image view of 32-bit BGRA pixel format.
\param [in] col - x-coordinate of the pixel.
\param [in] row - y-coordinate of the pixel.
\return a constant reference to the pixel.
*/
template <template<class> class A> static const Bgra32 & At(const View<A> & view, ptrdiff_t col, ptrdiff_t row);
/*!
\fn template <template<class> class A> static Bgr32 & At(View<A> & view, ptrdiff_t col, ptrdiff_t row);
Gets reference to the pixel with specific coordinates at the image view.
\param [in] view - an image view of 32-bit BGRA pixel format.
\param [in] col - x-coordinate of the pixel.
\param [in] row - y-coordinate of the pixel.
\return a reference to the pixel.
*/
template <template<class> class A> static Bgra32 & At(View<A> & view, ptrdiff_t col, ptrdiff_t row);
};
/*! @ingroup cpp_pixels
\short 24-bit HSV pixel.
Provides manipulation of 24-bit HSV (Hue, Saturation, Value) pixels of the View struct.
*/
struct Hsv24
{
uint8_t hue; /*!< \brief 8-bit hue channel 24-bit HSV pixel. */
uint8_t saturation; /*!< \brief 8-bit saturation channel 24-bit HSV pixel. */
uint8_t value; /*!< \brief 8-bit value channel 24-bit HSV pixel. */
/*!
Creates a new 24-bit HSV pixel structure with specified channel values.
\param [in] gray - initial value for value channel. It is equal to 0 by default.
*/
Hsv24(const uint8_t & gray = uint8_t(0));
/*!
Creates a new 24-bit HSV pixel structure with specified channel values.
\param [in] h - initial value for hue channel.
\param [in] s - initial value for saturation channel.
\param [in] v - initial value for value channel.
*/
Hsv24(const uint8_t & h, const uint8_t & s, const uint8_t & v);
/*!
Creates a copy of 24-bit HSV pixel structure.
\param [in] p - 24-bit HSV pixel.
*/
Hsv24(const Hsv24 & p);
/*!
\fn template <template<class> class A> static const Hsv24 & At(const View<A> & view, ptrdiff_t col, ptrdiff_t row);
Gets constant reference to the pixel with specific coordinates at the image view.
\param [in] view - an image view of 24-bit HSV pixel format.
\param [in] col - x-coordinate of the pixel.
\param [in] row - y-coordinate of the pixel.
\return a constant reference to the pixel.
*/
template <template<class> class A> static const Hsv24 & At(const View<A> & view, ptrdiff_t col, ptrdiff_t row);
/*!
\fn template <template<class> class A> static Hsv24 & At(View<A> & view, ptrdiff_t col, ptrdiff_t row);
Gets reference to the pixel with specific coordinates at the image view.
\param [in] view - an image view of 24-bit HSV pixel format.
\param [in] col - x-coordinate of the pixel.
\param [in] row - y-coordinate of the pixel.
\return a reference to the pixel.
*/
template <template<class> class A> static Hsv24 & At(View<A> & view, ptrdiff_t col, ptrdiff_t row);
};
/*! @ingroup cpp_pixels
\short 24-bit HSL pixel.
Provides manipulation of 24-bit HSL (Hue, Saturation, Lightness) pixels of the View struct.
*/
struct Hsl24
{
uint8_t hue; /*!< \brief 8-bit hue channel 24-bit HSL pixel. */
uint8_t saturation; /*!< \brief 8-bit saturation channel 24-bit HSL pixel. */
uint8_t lightness; /*!< \brief 8-bit lightness channel 24-bit HSL pixel. */
/*!
Creates a new 24-bit HSL pixel structure with specified channel values.
\param [in] gray - initial value for value channel. It is equal to 0 by default.
*/
Hsl24(const uint8_t & gray = uint8_t(0));
/*!
Creates a new 24-bit HSL pixel structure with specified channel values.
\param [in] h - initial value for hue channel.
\param [in] s - initial value for saturation channel.
\param [in] l - initial value for lightness channel.
*/
Hsl24(const uint8_t & h, const uint8_t & s, const uint8_t & l);
/*!
Creates a copy of 24-bit HSL pixel structure.
\param [in] p - 24-bit HSL pixel.
*/
Hsl24(const Hsl24 & p);
/*!
\fn template <template<class> class A> static const Hsl24 & At(const View<A> & view, ptrdiff_t col, ptrdiff_t row);
Gets constant reference to the pixel with specific coordinates at the image view.
\param [in] view - an image view of 24-bit HSL pixel format.
\param [in] col - x-coordinate of the pixel.
\param [in] row - y-coordinate of the pixel.
\return a constant reference to the pixel.
*/
template <template<class> class A> static const Hsl24 & At(const View<A> & view, ptrdiff_t col, ptrdiff_t row);
/*!
\fn template <template<class> class A> static Hsl24 & At(View<A> & view, ptrdiff_t col, ptrdiff_t row);
Gets reference to the pixel with specific coordinates at the image view.
\param [in] view - an image view of 24-bit HSL pixel format.
\param [in] col - x-coordinate of the pixel.
\param [in] row - y-coordinate of the pixel.
\return a reference to the pixel.
*/
template <template<class> class A> static Hsl24 & At(View<A> & view, ptrdiff_t col, ptrdiff_t row);
};
/*! @ingroup cpp_pixels
\short 24-bit RGB pixel.
Provides manipulation of 24-bit RGB (Red, Blue, Green) pixels of the View struct.
*/
struct Rgb24
{
uint8_t red; /*!< \brief 8-bit red channel 24-bit BGR pixel. */
uint8_t green; /*!< \brief 8-bit green channel 24-bit BGR pixel. */
uint8_t blue; /*!< \brief 8-bit blue channel 24-bit BGR pixel. */
/*!
Creates a new 24-bit RGB pixel structure with specified channel values.
\param [in] gray - initial value for all channels. It is equal to 0 by default.
*/
Rgb24(const uint8_t & gray = uint8_t(0));
/*!
Creates a new 24-bit RGB pixel structure with specified channel values.
\param [in] r - initial value for red channel.
\param [in] g - initial value for green channel.
\param [in] b - initial value for blue channel.
*/
Rgb24(const uint8_t & r, const uint8_t & g, const uint8_t & b);
/*!
Creates a new 24-bit RGB pixel structure on the base of 32-bit BGRA pixel.
\param [in] p - 32-bit BGRA pixel.
*/
Rgb24(const Bgra32 & p);
/*!
Creates a new 24-bit RGB pixel structure on the base of 24-bit BGR pixel.
\param [in] p - 24-bit BGR pixel.
*/
Rgb24(const Bgr24 & p);
/*!
Creates a new 24-bit RGB pixel structure on the base of 32-bit RGBA pixel.
\param [in] p - 32-bit RGBA pixel.
*/
Rgb24(const Rgba32& p);
/*!
Creates a copy of 24-bit RGB pixel structure.
\param [in] p - 24-bit RGB pixel.
*/
Rgb24(const Rgb24 & p);
/*!
\fn template <template<class> class A> static const Rgb24 & At(const View<A> & view, ptrdiff_t col, ptrdiff_t row);
Gets constant reference to the pixel with specific coordinates at the image view.
\param [in] view - an image view of 24-bit RGB pixel format.
\param [in] col - x-coordinate of the pixel.
\param [in] row - y-coordinate of the pixel.
\return a constant reference to the pixel.
*/
template <template<class> class A> static const Rgb24 & At(const View<A> & view, ptrdiff_t col, ptrdiff_t row);
/*!
\fn template <template<class> class A> static Rgb24 & At(View<A> & view, ptrdiff_t col, ptrdiff_t row);
Gets reference to the pixel with specific coordinates at the image view.
\param [in] view - an image view of 24-bit RGB pixel format.
\param [in] col - x-coordinate of the pixel.
\param [in] row - y-coordinate of the pixel.
\return a reference to the pixel.
*/
template <template<class> class A> static Rgb24 & At(View<A> & view, ptrdiff_t col, ptrdiff_t row);
};
/*! @ingroup cpp_pixels
\short 32-bit RGBA pixel.
Provides manipulation of 32-bit RGBA (Red, Blue, Green, Alpha) pixels of the View struct.
*/
struct Rgba32
{
uint8_t red; /*!< \brief 8-bit red channel 32-bit BGRA pixel. */
uint8_t green; /*!< \brief 8-bit green channel 32-bit BGRA pixel. */
uint8_t blue; /*!< \brief 8-bit blue channel 32-bit BGRA pixel. */
uint8_t alpha; /*!< \brief 8-bit alpha channel 32-bit RGBA pixel. */
/*!
Creates a new 32-bit RGBA pixel structure with specified channel values.
\param [in] gray - initial value for all channels. It is equal to 0 by default.
\param [in] a - initial value for alpha channel. It is equal to 255 by default.
*/
Rgba32(const uint8_t& gray = uint8_t(0), const uint8_t& a = uint8_t(255));
/*!
Creates a new 32-bit RGBA pixel structure with specified channel values.
\param [in] r - initial value for red channel.
\param [in] g - initial value for green channel.
\param [in] b - initial value for blue channel.
\param [in] a - initial value for alpha channel. It is equal to 255 by default.
*/
Rgba32(const uint8_t& r, const uint8_t& g, const uint8_t& b, const uint8_t& a = uint8_t(255));
/*!
Creates a new 32-bit RGBA pixel structure on the base of 32-bit BGRA pixel.
\param [in] p - 32-bit BGRA pixel.
*/
Rgba32(const Bgra32& p);
/*!
Creates a new 32-bit RGBA pixel structure on the base of 24-bit BGR pixel.
\param [in] p - 24-bit BGR pixel.
\param [in] a - initial value for alpha channel. It is equal to 255 by default.
*/
Rgba32(const Bgr24& p, const uint8_t& a = uint8_t(255));
/*!
Creates a new of 32-bit RGBA pixel structure on the base of 24-bit RGB pixel.
\param [in] p - 24-bit RGB pixel.
\param [in] a - initial value for alpha channel. It is equal to 255 by default.
*/
Rgba32(const Rgb24& p, const uint8_t& a = uint8_t(255));
/*!
Creates a copy of 32-bit RGBA pixel structure.
\param [in] p - 32-bit RGBA pixel.
*/
Rgba32(const Rgba32& p);
/*!
\fn template <template<class> class A> static const Rgba32 & At(const View<A> & view, ptrdiff_t col, ptrdiff_t row);
Gets constant reference to the pixel with specific coordinates at the image view.
\param [in] view - an image view of 32-bit RGBA pixel format.
\param [in] col - x-coordinate of the pixel.
\param [in] row - y-coordinate of the pixel.
\return a constant reference to the pixel.
*/
template <template<class> class A> static const Rgba32& At(const View<A>& view, ptrdiff_t col, ptrdiff_t row);
/*!
\fn template <template<class> class A> static Rgba32 & At(View<A> & view, ptrdiff_t col, ptrdiff_t row);
Gets reference to the pixel with specific coordinates at the image view.
\param [in] view - an image view of 32-bit RGBA pixel format.
\param [in] col - x-coordinate of the pixel.
\param [in] row - y-coordinate of the pixel.
\return a reference to the pixel.
*/
template <template<class> class A> static Rgba32& At(View<A>& view, ptrdiff_t col, ptrdiff_t row);
};
//-------------------------------------------------------------------------
// struct Bgr24 implementation:
SIMD_INLINE Bgr24::Bgr24(const uint8_t & gray)
: blue(gray)
, green(gray)
, red(gray)
{
}
SIMD_INLINE Bgr24::Bgr24(const uint8_t & b, const uint8_t & g, const uint8_t & r)
: blue(b)
, green(g)
, red(r)
{
}
SIMD_INLINE Bgr24::Bgr24(const Bgra32 & p)
: blue(p.blue)
, green(p.green)
, red(p.red)
{
}
SIMD_INLINE Bgr24::Bgr24(const Rgb24 & p)
: blue(p.blue)
, green(p.green)
, red(p.red)
{
}
SIMD_INLINE Bgr24::Bgr24(const Rgba32& p)
: blue(p.blue)
, green(p.green)
, red(p.red)
{
}
SIMD_INLINE Bgr24::Bgr24(const Bgr24 & p)
: blue(p.blue)
, green(p.green)
, red(p.red)
{
}
template <template<class> class A> SIMD_INLINE const Bgr24 & Bgr24::At(const View<A> & view, ptrdiff_t col, ptrdiff_t row)
{
assert(view.format == View<A>::Bgr24);
return Simd::At<A, Bgr24>(view, col, row);
}
template <template<class> class A> SIMD_INLINE Bgr24 & Bgr24::At(View<A> & view, ptrdiff_t col, ptrdiff_t row)
{
assert(view.format == View<A>::Bgr24);
return Simd::At<A, Bgr24>(view, col, row);
}
// struct Bgra32 implementation:
SIMD_INLINE Bgra32::Bgra32(const uint8_t & gray, const uint8_t & a)
: blue(gray)
, green(gray)
, red(gray)
, alpha(a)
{
}
SIMD_INLINE Bgra32::Bgra32(const uint8_t & b, const uint8_t & g, const uint8_t & r, const uint8_t & a)
: blue(b)
, green(g)
, red(r)
, alpha(a)
{
}
SIMD_INLINE Bgra32::Bgra32(const Bgr24 & p, const uint8_t & a)
: blue(p.blue)
, green(p.green)
, red(p.red)
, alpha(a)
{
}
SIMD_INLINE Bgra32::Bgra32(const Rgb24 & p, const uint8_t & a)
: blue(p.blue)
, green(p.green)
, red(p.red)
, alpha(a)
{
}
SIMD_INLINE Bgra32::Bgra32(const Rgba32& p)
: blue(p.blue)
, green(p.green)
, red(p.red)
, alpha(p.alpha)
{
}
SIMD_INLINE Bgra32::Bgra32(const Bgra32 & p)
: blue(p.blue)
, green(p.green)
, red(p.red)
, alpha(p.alpha)
{
}
template <template<class> class A> SIMD_INLINE const Bgra32 & Bgra32::At(const View<A> & view, ptrdiff_t col, ptrdiff_t row)
{
assert(view.format == View<A>::Bgra32);
return Simd::At<A, Bgra32>(view, col, row);
}
template <template<class> class A> SIMD_INLINE Bgra32 & Bgra32::At(View<A> & view, ptrdiff_t col, ptrdiff_t row)
{
assert(view.format == View<A>::Bgra32);
return Simd::At<A, Bgra32>(view, col, row);
}
// struct Hsv24 implementation:
SIMD_INLINE Hsv24::Hsv24(const uint8_t & gray)
: hue(0)
, saturation(0)
, value(gray)
{
}
SIMD_INLINE Hsv24::Hsv24(const uint8_t & h, const uint8_t & s, const uint8_t & v)
: hue(h)
, saturation(s)
, value(v)
{
}
SIMD_INLINE Hsv24::Hsv24(const Hsv24 & p)
: hue(p.hue)
, saturation(p.saturation)
, value(p.value)
{
}
template <template<class> class A> SIMD_INLINE const Hsv24 & Hsv24::At(const View<A> & view, ptrdiff_t col, ptrdiff_t row)
{
assert(view.format == View<A>::Hsv24);
return Simd::At<A, Hsv24>(view, col, row);
}
template <template<class> class A> SIMD_INLINE Hsv24 & Hsv24::At(View<A> & view, ptrdiff_t col, ptrdiff_t row)
{
assert(view.format == View<A>::Hsv24);
return Simd::At<A, Hsv24>(view, col, row);
}
// struct Hsl24 implementation:
SIMD_INLINE Hsl24::Hsl24(const uint8_t & gray)
: hue(0)
, saturation(0)
, lightness(gray)
{
}
SIMD_INLINE Hsl24::Hsl24(const uint8_t & h, const uint8_t & s, const uint8_t & l)
: hue(h)
, saturation(s)
, lightness(l)
{
}
SIMD_INLINE Hsl24::Hsl24(const Hsl24 & p)
: hue(p.hue)
, saturation(p.saturation)
, lightness(p.lightness)
{
}
template <template<class> class A> SIMD_INLINE const Hsl24 & Hsl24::At(const View<A> & view, ptrdiff_t col, ptrdiff_t row)
{
assert(view.format == View<A>::Hsl24);
return Simd::At<A, Hsl24>(view, col, row);
}
template <template<class> class A> SIMD_INLINE Hsl24 & Hsl24::At(View<A> & view, ptrdiff_t col, ptrdiff_t row)
{
assert(view.format == View<A>::Hsl24);
return Simd::At<A, Hsl24>(view, col, row);
}
// struct Rgb24 implementation:
SIMD_INLINE Rgb24::Rgb24(const uint8_t & gray)
: red(gray)
, green(gray)
, blue(gray)
{
}
SIMD_INLINE Rgb24::Rgb24(const uint8_t & r, const uint8_t & g, const uint8_t & b)
: red(r)
, green(g)
, blue(b)
{
}
SIMD_INLINE Rgb24::Rgb24(const Bgra32 & p)
: red(p.red)
, green(p.green)
, blue(p.blue)
{
}
SIMD_INLINE Rgb24::Rgb24(const Bgr24 & p)
: red(p.red)
, green(p.green)
, blue(p.blue)
{
}
SIMD_INLINE Rgb24::Rgb24(const Rgba32& p)
: red(p.red)
, green(p.green)
, blue(p.blue)
{
}
SIMD_INLINE Rgb24::Rgb24(const Rgb24 & p)
: red(p.red)
, green(p.green)
, blue(p.blue)
{
}
template <template<class> class A> SIMD_INLINE const Rgb24 & Rgb24::At(const View<A> & view, ptrdiff_t col, ptrdiff_t row)
{
assert(view.format == View<A>::Rgb24);
return Simd::At<A, Rgb24>(view, col, row);
}
template <template<class> class A> SIMD_INLINE Rgb24 & Rgb24::At(View<A> & view, ptrdiff_t col, ptrdiff_t row)
{
assert(view.format == View<A>::Rgb24);
return Simd::At<A, Rgb24>(view, col, row);
}
// struct Rgba32 implementation:
SIMD_INLINE Rgba32::Rgba32(const uint8_t& gray, const uint8_t& a)
: red(gray)
, green(gray)
, blue(gray)
, alpha(a)
{
}
SIMD_INLINE Rgba32::Rgba32(const uint8_t& r, const uint8_t& g, const uint8_t& b, const uint8_t& a)
: red(r)
, green(g)
, blue(b)
, alpha(a)
{
}
SIMD_INLINE Rgba32::Rgba32(const Bgra32& p)
: red(p.red)
, green(p.green)
, blue(p.blue)
, alpha(p.alpha)
{
}
SIMD_INLINE Rgba32::Rgba32(const Bgr24& p, const uint8_t& a)
: red(p.red)
, green(p.green)
, blue(p.blue)
, alpha(a)
{
}
SIMD_INLINE Rgba32::Rgba32(const Rgb24& p, const uint8_t& a)
: red(p.red)
, green(p.green)
, blue(p.blue)
, alpha(a)
{
}
SIMD_INLINE Rgba32::Rgba32(const Rgba32& p)
: red(p.red)
, green(p.green)
, blue(p.blue)
, alpha(p.alpha)
{
}
template <template<class> class A> SIMD_INLINE const Rgba32& Rgba32::At(const View<A>& view, ptrdiff_t col, ptrdiff_t row)
{
assert(view.format == View<A>::Rgba32);
return Simd::At<A, Rgba32>(view, col, row);
}
template <template<class> class A> SIMD_INLINE Rgba32& Rgba32::At(View<A>& view, ptrdiff_t col, ptrdiff_t row)
{
assert(view.format == View<A>::Rgba32);
return Simd::At<A, Rgba32>(view, col, row);
}
}
}
#endif//__SimdPixel_hpp__
|