Skip to content

Commit 8a3176b

Browse files
author
Reini Urban
committed
Document the RGBA structure
1 parent af7b2d5 commit 8a3176b

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

common/include/pcl/impl/point_types.hpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -342,20 +342,20 @@ namespace pcl
342342
PCL_EXPORTS std::ostream& operator << (std::ostream& os, const RGB& p);
343343
/** \brief A structure representing RGB color information.
344344
*
345-
* The RGBA information is available either as separate r, g, b, or as a
346-
* packed std::uint32_t rgba value. To pack it, use:
345+
* The RGB information is available either as separate r, g, b or as a
346+
* packed std::uint32_t rgb value. To pack it, use:
347347
*
348348
* \code
349-
* int rgb = ((int)r) << 16 | ((int)g) << 8 | ((int)b);
349+
* std::uint32_t rgb = ((int)r) << 16 | ((int)g) << 8 | ((int)b);
350350
* \endcode
351351
*
352352
* To unpack it use:
353353
*
354354
* \code
355-
* int rgb = ...;
355+
* std::uint32_t rgb = p.rgba;
356356
* std::uint8_t r = (rgb >> 16) & 0x0000ff;
357357
* std::uint8_t g = (rgb >> 8) & 0x0000ff;
358-
* std::uint8_t b = (rgb) & 0x0000ff;
358+
* std::uint8_t b = (rgb) & 0x0000ff;
359359
* \endcode
360360
*
361361
*/
@@ -506,20 +506,22 @@ namespace pcl
506506
PCL_EXPORTS std::ostream& operator << (std::ostream& os, const PointXYZRGBA& p);
507507
/** \brief A point structure representing Euclidean xyz coordinates, and the RGBA color.
508508
*
509-
* The RGBA information is available either as separate r, g, b, or as a
510-
* packed std::uint32_t rgba value. To pack it, use:
509+
* The RGBA information is available either as separate r, g, b and a uint8_t values,
510+
* or as a packed std::uint32_t rgba value. To pack it, use:
511511
*
512512
* \code
513-
* int rgb = ((int)r) << 16 | ((int)g) << 8 | ((int)b);
513+
* std::uint32_t rgba = ((std::uint32_t)a << 24 | ((std::uint32_t)r << 16 | ((std::uint32_t)g << 8) | b;
514514
* \endcode
515515
*
516516
* To unpack it use:
517517
*
518518
* \code
519-
* int rgb = ...;
519+
* // unpack rgb into r/g/b
520+
* std::uint32_t rgb = p.rgba;
521+
* std::uint8_t a = (rgb >> 24) & 0x0000ff;
520522
* std::uint8_t r = (rgb >> 16) & 0x0000ff;
521523
* std::uint8_t g = (rgb >> 8) & 0x0000ff;
522-
* std::uint8_t b = (rgb) & 0x0000ff;
524+
* std::uint8_t b = (rgb) & 0x0000ff;
523525
* \endcode
524526
*
525527
* \ingroup common
@@ -579,7 +581,7 @@ namespace pcl
579581
* \code
580582
* PointXYZRGB p;
581583
* // unpack rgb into r/g/b
582-
* std::uint32_t rgb = *reinterpret_cast<int*>(&p.rgb);
584+
* std::uint32_t rgb = p.rgb;
583585
* std::uint8_t r = (rgb >> 16) & 0x0000ff;
584586
* std::uint8_t g = (rgb >> 8) & 0x0000ff;
585587
* std::uint8_t b = (rgb) & 0x0000ff;
@@ -899,7 +901,7 @@ namespace pcl
899901
* \code
900902
* PointXYZRGB p;
901903
* // unpack rgb into r/g/b
902-
* std::uint32_t rgb = *reinterpret_cast<int*>(&p.rgb);
904+
* std::uint32_t rgb = p.rgba;
903905
* std::uint8_t r = (rgb >> 16) & 0x0000ff;
904906
* std::uint8_t g = (rgb >> 8) & 0x0000ff;
905907
* std::uint8_t b = (rgb) & 0x0000ff;

0 commit comments

Comments
 (0)