File library for Bitmap images (*.bmp, *.dib). Currently supports only Windows V3 format with 24-bit-per-pixel color depth.
Revision 2:89b273c12b0a, committed 2015-03-05
- Comitter:
- kayekss
- Date:
- Thu Mar 05 01:56:29 2015 +0000
- Parent:
- 1:8cf4beca9695
- Child:
- 3:be3e831a86c1
- Commit message:
- Fixed wrong array index in function "red"
Changed in this revision
BMPFile.cpp | Show annotated file Show diff for this revision Revisions of this file |
BMPFile.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/BMPFile.cpp Wed Mar 04 20:56:34 2015 +0000 +++ b/BMPFile.cpp Thu Mar 05 01:56:29 2015 +0000 @@ -272,9 +272,9 @@ case 16: // BGR565 (bbbbbggg:gggrrrrr) return data[stride * y + 2 * x + 1] & 0x1f; case 24: // BGR888 - return data[stride * y + 3 * x + 1]; + return data[stride * y + 3 * x + 2]; case 32: // BGRX8888 - return data[stride * y + 4 * x + 1]; + return data[stride * y + 4 * x + 2]; default: return -1; }
--- a/BMPFile.h Wed Mar 04 20:56:34 2015 +0000 +++ b/BMPFile.h Thu Mar 05 01:56:29 2015 +0000 @@ -84,21 +84,35 @@ int32_t red(uint32_t x, uint32_t y); /** Get green value of specified pixel. + * This method returns -1 for outranged pixels. * @param x X-coordinate of the pixel. * @param y Y-coordinate of the pixel. */ int32_t green(uint32_t x, uint32_t y); /** Get blue value of specified pixel. + * This method returns -1 for outranged pixels. * @param x X-coordinate of the pixel. * @param y Y-coordinate of the pixel. */ int32_t blue(uint32_t x, uint32_t y); - + + /** Get red value from palette. + * This method returns -1 for non-indexed image or outranged indexes. + * @param index Palette color index. + */ int32_t paletteRed(uint8_t index); + /** Get green value from palette. + * This method returns -1 for non-indexed image or outranged indexes. + * @param index Palette color index. + */ int32_t paletteGreen(uint8_t index); + /** Get blue value from palette. + * This method returns -1 for non-indexed image or outranged indexes. + * @param index Palette color index. + */ int32_t paletteBlue(uint8_t index); private: