diff options
| author | Carl Hetherington <cth@carlh.net> | 2012-08-21 19:07:10 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2012-08-21 19:07:10 +0100 |
| commit | 3541f4c9bd91169e55a82b9fa46767b46ca06188 (patch) | |
| tree | bb3612debc5df953c9dd09d8a0346d6351709f4e /src/picture_frame.cc | |
| parent | 283de7f01cffe219dc7dd3267a91e9f1ccda1f69 (diff) | |
Clarify (a bit) byte ordering for RGBA frames.
Diffstat (limited to 'src/picture_frame.cc')
| -rw-r--r-- | src/picture_frame.cc | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/picture_frame.cc b/src/picture_frame.cc index 844f0183..09ef4ae4 100644 --- a/src/picture_frame.cc +++ b/src/picture_frame.cc @@ -22,7 +22,7 @@ #include "KM_fileio.h" #include "picture_frame.h" #include "exceptions.h" -#include "rgba_frame.h" +#include "argb_frame.h" #include "lut.h" using namespace std; @@ -61,8 +61,12 @@ PictureFrame::size () const return _buffer->Size (); } -shared_ptr<RGBAFrame> -PictureFrame::rgba_frame () const +/** @return An ARGB representation of this frame. This is ARGB in the + * Cairo sense, so that each pixel takes up 4 bytes; the first byte + * is blue, second green, third red and fourth alpha (always 255). + */ +shared_ptr<ARGBFrame> +PictureFrame::argb_frame () const { /* JPEG2000 -> decompressed XYZ */ @@ -94,12 +98,12 @@ PictureFrame::rgba_frame () const int* xyz_y = xyz_frame->comps[1].data; int* xyz_z = xyz_frame->comps[2].data; - shared_ptr<RGBAFrame> rgba_frame (new RGBAFrame (xyz_frame->x1, xyz_frame->y1)); + shared_ptr<ARGBFrame> argb_frame (new ARGBFrame (xyz_frame->x1, xyz_frame->y1)); - uint8_t* rgba = rgba_frame->data (); + uint8_t* argb = argb_frame->data (); for (int y = 0; y < xyz_frame->y1; ++y) { - uint8_t* rgba_line = rgba; + uint8_t* argb_line = argb; for (int x = 0; x < xyz_frame->x1; ++x) { assert (*xyz_x >= 0 && *xyz_y >= 0 && *xyz_z >= 0 && *xyz_x < 4096 && *xyz_x < 4096 && *xyz_z < 4096); @@ -129,17 +133,17 @@ PictureFrame::rgba_frame () const d.b = max (d.b, 0.0); /* Out gamma LUT */ - *rgba_line++ = lut_out[(int) (d.r * COLOR_DEPTH)]; - *rgba_line++ = lut_out[(int) (d.g * COLOR_DEPTH)]; - *rgba_line++ = lut_out[(int) (d.b * COLOR_DEPTH)]; - *rgba_line++ = 0xff; + *argb_line++ = lut_out[(int) (d.b * COLOR_DEPTH)]; + *argb_line++ = lut_out[(int) (d.g * COLOR_DEPTH)]; + *argb_line++ = lut_out[(int) (d.r * COLOR_DEPTH)]; + *argb_line++ = 0xff; } - rgba += rgba_frame->stride (); + argb += argb_frame->stride (); } opj_cio_close (cio); opj_image_destroy (xyz_frame); - return rgba_frame; + return argb_frame; } |
