From: DRC Date: Fri, 17 Nov 2017 02:43:12 +0000 (-0600) Subject: TurboJPEG: Add alpha offset array/method X-Git-Tag: 1.5.90~53 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dc4b900223eab0282d315a06c0cc4176c627516c;p=libjpeg-turbo TurboJPEG: Add alpha offset array/method Also, set the red/green/blue offsets for TJPF_GRAY to -1 rather than 0. It was undefined behavior for an application to use those arrays/methods with TJPF_GRAY anyhow, and this makes it easier for applications to programmatically detect whether a given pixel format has red, green, and blue components. --- diff --git a/ChangeLog.md b/ChangeLog.md index 11dcd16..599c839 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -110,6 +110,16 @@ TJBench, and they also provide a convenient way for first-time users of libjpeg-turbo to quickly develop a complete JPEG compression/decompression program. +14. The TurboJPEG C API now includes a new convenience array +(`tjAlphaOffset[]`) that contains the alpha component index for each pixel +format (or -1 if the pixel format lacks an alpha component.) The TurboJPEG +Java API now includes a new method (`TJ.getAlphaOffset()`) that returns the +same value. In addition, the `tjRedOffset[]`, `tjGreenOffset[]`, and +`tjBlueOffset[]` arrays-- and the corresponding `TJ.getRedOffset()`, +`TJ.getGreenOffset()`, and `TJ.getBlueOffset()` methods-- now return -1 for +`TJPF_GRAY`/`TJ.PF_GRAY` rather than 0. This allows programs to easily +determine whether a pixel format has red, green, blue, and alpha components. + 1.5.2 ===== diff --git a/doc/html/group___turbo_j_p_e_g.html b/doc/html/group___turbo_j_p_e_g.html index 402b858..4dc6030 100644 --- a/doc/html/group___turbo_j_p_e_g.html +++ b/doc/html/group___turbo_j_p_e_g.html @@ -347,6 +347,9 @@ Variables static const int tjBlueOffset [TJ_NUMPF]  Blue offset (in bytes) for a given pixel format. More...
  +static const int tjAlphaOffset [TJ_NUMPF] + Alpha offset (in bytes) for a given pixel format. More...
+  static const int tjPixelSize [TJ_NUMPF]  Pixel size (in bytes) for a given pixel format. More...
  @@ -2581,6 +2584,29 @@ If you choose option 1, dstSizes[i] should be set to the size of yo

Variable Documentation

+ +
+
+ + + + + +
+ + + + +
const int tjAlphaOffset[TJ_NUMPF]
+
+static
+
+ +

Alpha offset (in bytes) for a given pixel format.

+

This specifies the number of bytes that the Alpha component is offset from the start of the pixel. For instance, if a pixel of format TJ_BGRA is stored in char pixel[], then the alpha component will be pixel[tjAlphaOffset[TJ_BGRA]]. This will be -1 if the pixel format does not have an alpha component.

+ +
+
@@ -2600,7 +2626,7 @@ If you choose option 1, dstSizes[i] should be set to the size of yo

Blue offset (in bytes) for a given pixel format.

-

This specifies the number of bytes that the Blue component is offset from the start of the pixel. For instance, if a pixel of format TJ_BGRX is stored in char pixel[], then the blue component will be pixel[tjBlueOffset[TJ_BGRX]].

+

This specifies the number of bytes that the Blue component is offset from the start of the pixel. For instance, if a pixel of format TJ_BGRX is stored in char pixel[], then the blue component will be pixel[tjBlueOffset[TJ_BGRX]]. This will be -1 if the pixel format does not have a blue component.

@@ -2623,7 +2649,7 @@ If you choose option 1, dstSizes[i] should be set to the size of yo

Green offset (in bytes) for a given pixel format.

-

This specifies the number of bytes that the green component is offset from the start of the pixel. For instance, if a pixel of format TJ_BGRX is stored in char pixel[], then the green component will be pixel[tjGreenOffset[TJ_BGRX]].

+

This specifies the number of bytes that the green component is offset from the start of the pixel. For instance, if a pixel of format TJ_BGRX is stored in char pixel[], then the green component will be pixel[tjGreenOffset[TJ_BGRX]]. This will be -1 if the pixel format does not have a green component.

@@ -2728,7 +2754,7 @@ If you choose option 1, dstSizes[i] should be set to the size of yo

Red offset (in bytes) for a given pixel format.

-

This specifies the number of bytes that the red component is offset from the start of the pixel. For instance, if a pixel of format TJ_BGRX is stored in char pixel[], then the red component will be pixel[tjRedOffset[TJ_BGRX]].

+

This specifies the number of bytes that the red component is offset from the start of the pixel. For instance, if a pixel of format TJ_BGRX is stored in char pixel[], then the red component will be pixel[tjRedOffset[TJ_BGRX]]. This will be -1 if the pixel format does not have a red component.

diff --git a/doc/html/search/all_74.js b/doc/html/search/all_74.js index e952119..fe7e697 100644 --- a/doc/html/search/all_74.js +++ b/doc/html/search/all_74.js @@ -6,6 +6,7 @@ var searchData= ['tj_5fnumsamp',['TJ_NUMSAMP',['../group___turbo_j_p_e_g.html#ga5ef3d169162ce77ce348e292a0b7477c',1,'turbojpeg.h']]], ['tj_5fnumxop',['TJ_NUMXOP',['../group___turbo_j_p_e_g.html#ga0f6dbd18adf38b7d46ac547f0f4d562c',1,'turbojpeg.h']]], ['tjalloc',['tjAlloc',['../group___turbo_j_p_e_g.html#ga5c9234bda6d993cdaffdd89bf81a00ff',1,'turbojpeg.h']]], + ['tjalphaoffset',['tjAlphaOffset',['../group___turbo_j_p_e_g.html#ga5af0ab065feefd526debf1e20c43e837',1,'turbojpeg.h']]], ['tjblueoffset',['tjBlueOffset',['../group___turbo_j_p_e_g.html#ga84e2e35d3f08025f976ec1ec53693dea',1,'turbojpeg.h']]], ['tjbufsize',['tjBufSize',['../group___turbo_j_p_e_g.html#gaccc5bca7f12fcdcc302e6e1c6d4b311b',1,'turbojpeg.h']]], ['tjbufsizeyuv2',['tjBufSizeYUV2',['../group___turbo_j_p_e_g.html#gaf451664a62c1f6c7cc5a6401f32908c9',1,'turbojpeg.h']]], diff --git a/doc/html/search/variables_74.js b/doc/html/search/variables_74.js index 13a056e..2d20942 100644 --- a/doc/html/search/variables_74.js +++ b/doc/html/search/variables_74.js @@ -1,5 +1,6 @@ var searchData= [ + ['tjalphaoffset',['tjAlphaOffset',['../group___turbo_j_p_e_g.html#ga5af0ab065feefd526debf1e20c43e837',1,'turbojpeg.h']]], ['tjblueoffset',['tjBlueOffset',['../group___turbo_j_p_e_g.html#ga84e2e35d3f08025f976ec1ec53693dea',1,'turbojpeg.h']]], ['tjgreenoffset',['tjGreenOffset',['../group___turbo_j_p_e_g.html#ga82d6e35da441112a411da41923c0ba2f',1,'turbojpeg.h']]], ['tjmcuheight',['tjMCUHeight',['../group___turbo_j_p_e_g.html#gabd247bb9fecb393eca57366feb8327bf',1,'turbojpeg.h']]], diff --git a/java/TJUnitTest.java b/java/TJUnitTest.java index 47ff7bb..cd1b7a1 100644 --- a/java/TJUnitTest.java +++ b/java/TJUnitTest.java @@ -64,10 +64,6 @@ public class TJUnitTest { "RGBA", "BGRA", "ABGR", "ARGB", "CMYK" }; - private static final int[] alphaOffset = { - -1, -1, -1, -1, -1, -1, -1, 3, 3, 0, 0, -1 - }; - private static final int[] _3byteFormats = { TJ.PF_RGB, TJ.PF_BGR }; @@ -146,7 +142,7 @@ public class TJUnitTest { int roffset = TJ.getRedOffset(pf); int goffset = TJ.getGreenOffset(pf); int boffset = TJ.getBlueOffset(pf); - int aoffset = alphaOffset[pf]; + int aoffset = TJ.getAlphaOffset(pf); int ps = TJ.getPixelSize(pf); int index, row, col, halfway = 16; @@ -215,7 +211,7 @@ public class TJUnitTest { int rshift = TJ.getRedOffset(pf) * 8; int gshift = TJ.getGreenOffset(pf) * 8; int bshift = TJ.getBlueOffset(pf) * 8; - int ashift = alphaOffset[pf] * 8; + int ashift = TJ.getAlphaOffset(pf) * 8; int index, row, col, halfway = 16; Arrays.fill(buf, 0); @@ -298,7 +294,7 @@ public class TJUnitTest { int roffset = TJ.getRedOffset(pf); int goffset = TJ.getGreenOffset(pf); int boffset = TJ.getBlueOffset(pf); - int aoffset = alphaOffset[pf]; + int aoffset = TJ.getAlphaOffset(pf); int ps = TJ.getPixelSize(pf); int index, row, col, retval = 1; int halfway = 16 * sf.getNum() / sf.getDenom(); @@ -306,6 +302,9 @@ public class TJUnitTest { try { + if (pf == TJ.PF_GRAY) + roffset = goffset = boffset = 0; + if (pf == TJ.PF_CMYK) { for (row = 0; row < h; row++) { for (col = 0; col < w; col++) { @@ -422,7 +421,7 @@ public class TJUnitTest { int rshift = TJ.getRedOffset(pf) * 8; int gshift = TJ.getGreenOffset(pf) * 8; int bshift = TJ.getBlueOffset(pf) * 8; - int ashift = alphaOffset[pf] * 8; + int ashift = TJ.getAlphaOffset(pf) * 8; int index, row, col, retval = 1; int halfway = 16 * sf.getNum() / sf.getDenom(); int blockSize = 8 * sf.getNum() / sf.getDenom(); diff --git a/java/doc/constant-values.html b/java/doc/constant-values.html index 985784e..fb33327 100644 --- a/java/doc/constant-values.html +++ b/java/doc/constant-values.html @@ -7,8 +7,12 @@ diff --git a/java/doc/deprecated-list.html b/java/doc/deprecated-list.html index e47ffb1..31d4e64 100644 --- a/java/doc/deprecated-list.html +++ b/java/doc/deprecated-list.html @@ -7,8 +7,12 @@ diff --git a/java/doc/help-doc.html b/java/doc/help-doc.html index ce749a9..6645d95 100644 --- a/java/doc/help-doc.html +++ b/java/doc/help-doc.html @@ -7,8 +7,12 @@ diff --git a/java/doc/index-all.html b/java/doc/index-all.html index a9d139a..c2c59d8 100644 --- a/java/doc/index-all.html +++ b/java/doc/index-all.html @@ -7,8 +7,12 @@ @@ -349,6 +353,11 @@

G

+
getAlphaOffset(int) - Static method in class org.libjpegturbo.turbojpeg.TJ
+
+
For the given pixel format, returns the number of bytes that the alpha + component is offset from the start of the pixel.
+
getBlueOffset(int) - Static method in class org.libjpegturbo.turbojpeg.TJ
For the given pixel format, returns the number of bytes that the blue diff --git a/java/doc/index.html b/java/doc/index.html index b983957..4e21075 100644 --- a/java/doc/index.html +++ b/java/doc/index.html @@ -4,11 +4,12 @@ Generated Documentation (Untitled) @@ -417,53 +421,60 @@ extends java.lang.Object static int +getAlphaOffset(int pixelFormat) +
For the given pixel format, returns the number of bytes that the alpha + component is offset from the start of the pixel.
+ + + +static int getBlueOffset(int pixelFormat)
For the given pixel format, returns the number of bytes that the blue component is offset from the start of the pixel.
- + static int getGreenOffset(int pixelFormat)
For the given pixel format, returns the number of bytes that the green component is offset from the start of the pixel.
- + static int getMCUHeight(int subsamp)
Returns the MCU block height for the given level of chrominance subsampling.
- + static int getMCUWidth(int subsamp)
Returns the MCU block width for the given level of chrominance subsampling.
- + static int getPixelSize(int pixelFormat)
Returns the pixel size (in bytes) for the given pixel format.
- + static int getRedOffset(int pixelFormat)
For the given pixel format, returns the number of bytes that the red component is offset from the start of the pixel.
- + static TJScalingFactor[] getScalingFactors()
Returns a list of fractional scaling factors that the JPEG decompressor in this implementation of TurboJPEG supports.
- + static int planeHeight(int componentID, int height, @@ -471,7 +482,7 @@ extends java.lang.Object
Returns the plane height of a YUV image plane with the given parameters.
- + static int planeSizeYUV(int componentID, int width, @@ -482,7 +493,7 @@ extends java.lang.Object plane with the given parameters.
- + static int planeWidth(int componentID, int width, @@ -1137,7 +1148,8 @@ public static final int FLAG_FORCESSE3 then the red component will be pixel[TJ.getRedOffset(TJ.PF_BGRX)].
Parameters:
pixelFormat - the pixel format (one of PF_*)
-
Returns:
the red offset for the given pixel format.
+
Returns:
the red offset for the given pixel format, or -1 if the pixel + format does not have a red component.
@@ -1153,7 +1165,8 @@ public static final int FLAG_FORCESSE3 then the green component will be pixel[TJ.getGreenOffset(TJ.PF_BGRX)].
Parameters:
pixelFormat - the pixel format (one of PF_*)
-
Returns:
the green offset for the given pixel format.
+
Returns:
the green offset for the given pixel format, or -1 if the pixel + format does not have a green component.
@@ -1169,7 +1182,25 @@ public static final int FLAG_FORCESSE3 then the blue component will be pixel[TJ.getBlueOffset(TJ.PF_BGRX)].
Parameters:
pixelFormat - the pixel format (one of PF_*)
-
Returns:
the blue offset for the given pixel format.
+
Returns:
the blue offset for the given pixel format, or -1 if the pixel + format does not have a blue component.
+ + +
+ + +
    +
  • +

    getAlphaOffset

    +
    public static int getAlphaOffset(int pixelFormat)
    +
    For the given pixel format, returns the number of bytes that the alpha + component is offset from the start of the pixel. For instance, if a pixel + of format TJ.PF_BGRA is stored in char pixel[], + then the alpha component will be + pixel[TJ.getAlphaOffset(TJ.PF_BGRA)].
    +
    Parameters:
    pixelFormat - the pixel format (one of PF_*)
    +
    Returns:
    the alpha offset for the given pixel format, or -1 if the pixel + format does not have a alpha component.
diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJCompressor.html b/java/doc/org/libjpegturbo/turbojpeg/TJCompressor.html index 29f12b7..ea8c2be 100644 --- a/java/doc/org/libjpegturbo/turbojpeg/TJCompressor.html +++ b/java/doc/org/libjpegturbo/turbojpeg/TJCompressor.html @@ -7,8 +7,12 @@ diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJCustomFilter.html b/java/doc/org/libjpegturbo/turbojpeg/TJCustomFilter.html index 6bd6fd2..412dcd4 100644 --- a/java/doc/org/libjpegturbo/turbojpeg/TJCustomFilter.html +++ b/java/doc/org/libjpegturbo/turbojpeg/TJCustomFilter.html @@ -7,8 +7,12 @@ diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html b/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html index 8e33249..b281e32 100644 --- a/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html +++ b/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html @@ -7,8 +7,12 @@ diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJException.html b/java/doc/org/libjpegturbo/turbojpeg/TJException.html index a57b351..66d73e7 100644 --- a/java/doc/org/libjpegturbo/turbojpeg/TJException.html +++ b/java/doc/org/libjpegturbo/turbojpeg/TJException.html @@ -7,8 +7,12 @@ diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJScalingFactor.html b/java/doc/org/libjpegturbo/turbojpeg/TJScalingFactor.html index 35d6882..7722416 100644 --- a/java/doc/org/libjpegturbo/turbojpeg/TJScalingFactor.html +++ b/java/doc/org/libjpegturbo/turbojpeg/TJScalingFactor.html @@ -7,8 +7,12 @@ diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJTransform.html b/java/doc/org/libjpegturbo/turbojpeg/TJTransform.html index 86fafa3..5f22691 100644 --- a/java/doc/org/libjpegturbo/turbojpeg/TJTransform.html +++ b/java/doc/org/libjpegturbo/turbojpeg/TJTransform.html @@ -7,8 +7,12 @@ diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJTransformer.html b/java/doc/org/libjpegturbo/turbojpeg/TJTransformer.html index 36cbdb1..a30fe30 100644 --- a/java/doc/org/libjpegturbo/turbojpeg/TJTransformer.html +++ b/java/doc/org/libjpegturbo/turbojpeg/TJTransformer.html @@ -7,8 +7,12 @@ diff --git a/java/doc/org/libjpegturbo/turbojpeg/YUVImage.html b/java/doc/org/libjpegturbo/turbojpeg/YUVImage.html index b2be0a0..d4485ed 100644 --- a/java/doc/org/libjpegturbo/turbojpeg/YUVImage.html +++ b/java/doc/org/libjpegturbo/turbojpeg/YUVImage.html @@ -7,8 +7,12 @@ diff --git a/java/doc/org/libjpegturbo/turbojpeg/package-summary.html b/java/doc/org/libjpegturbo/turbojpeg/package-summary.html index f94656e..dedcce5 100644 --- a/java/doc/org/libjpegturbo/turbojpeg/package-summary.html +++ b/java/doc/org/libjpegturbo/turbojpeg/package-summary.html @@ -7,8 +7,12 @@ diff --git a/java/doc/org/libjpegturbo/turbojpeg/package-tree.html b/java/doc/org/libjpegturbo/turbojpeg/package-tree.html index 02a5cde..5f0f8c3 100644 --- a/java/doc/org/libjpegturbo/turbojpeg/package-tree.html +++ b/java/doc/org/libjpegturbo/turbojpeg/package-tree.html @@ -7,8 +7,12 @@ diff --git a/java/doc/overview-tree.html b/java/doc/overview-tree.html index 2ae76c6..b659995 100644 --- a/java/doc/overview-tree.html +++ b/java/doc/overview-tree.html @@ -7,8 +7,12 @@ diff --git a/java/doc/serialized-form.html b/java/doc/serialized-form.html index 9ba3fd9..45bbc86 100644 --- a/java/doc/serialized-form.html +++ b/java/doc/serialized-form.html @@ -7,8 +7,12 @@ diff --git a/java/org/libjpegturbo/turbojpeg/TJ.java b/java/org/libjpegturbo/turbojpeg/TJ.java index ee000a9..6624919 100644 --- a/java/org/libjpegturbo/turbojpeg/TJ.java +++ b/java/org/libjpegturbo/turbojpeg/TJ.java @@ -235,7 +235,8 @@ public final class TJ { * * @param pixelFormat the pixel format (one of PF_*) * - * @return the red offset for the given pixel format. + * @return the red offset for the given pixel format, or -1 if the pixel + * format does not have a red component. */ public static int getRedOffset(int pixelFormat) { checkPixelFormat(pixelFormat); @@ -243,7 +244,7 @@ public final class TJ { } private static final int[] redOffset = { - 0, 2, 0, 2, 3, 1, 0, 0, 2, 3, 1, -1 + 0, 2, 0, 2, 3, 1, -1, 0, 2, 3, 1, -1 }; @@ -256,7 +257,8 @@ public final class TJ { * * @param pixelFormat the pixel format (one of PF_*) * - * @return the green offset for the given pixel format. + * @return the green offset for the given pixel format, or -1 if the pixel + * format does not have a green component. */ public static int getGreenOffset(int pixelFormat) { checkPixelFormat(pixelFormat); @@ -264,7 +266,7 @@ public final class TJ { } private static final int[] greenOffset = { - 1, 1, 1, 1, 2, 2, 0, 1, 1, 2, 2, -1 + 1, 1, 1, 1, 2, 2, -1, 1, 1, 2, 2, -1 }; @@ -277,7 +279,8 @@ public final class TJ { * * @param pixelFormat the pixel format (one of PF_*) * - * @return the blue offset for the given pixel format. + * @return the blue offset for the given pixel format, or -1 if the pixel + * format does not have a blue component. */ public static int getBlueOffset(int pixelFormat) { checkPixelFormat(pixelFormat); @@ -285,7 +288,29 @@ public final class TJ { } private static final int[] blueOffset = { - 2, 0, 2, 0, 1, 3, 0, 2, 0, 1, 3, -1 + 2, 0, 2, 0, 1, 3, -1, 2, 0, 1, 3, -1 + }; + + + /** + * For the given pixel format, returns the number of bytes that the alpha + * component is offset from the start of the pixel. For instance, if a pixel + * of format TJ.PF_BGRA is stored in char pixel[], + * then the alpha component will be + * pixel[TJ.getAlphaOffset(TJ.PF_BGRA)]. + * + * @param pixelFormat the pixel format (one of PF_*) + * + * @return the alpha offset for the given pixel format, or -1 if the pixel + * format does not have a alpha component. + */ + public static int getAlphaOffset(int pixelFormat) { + checkPixelFormat(pixelFormat); + return alphaOffset[pixelFormat]; + } + + private static final int[] alphaOffset = { + -1, -1, -1, -1, -1, -1, -1, 3, 3, 0, 0, -1 }; diff --git a/tjunittest.c b/tjunittest.c index ffe6fc7..4c1475a 100644 --- a/tjunittest.c +++ b/tjunittest.c @@ -84,8 +84,6 @@ const char *pixFormatStr[TJ_NUMPF]= "RGBA", "BGRA", "ABGR", "ARGB", "CMYK" }; -const int alphaOffset[TJ_NUMPF] = {-1, -1, -1, -1, -1, -1, -1, 3, 3, 0, 0, -1}; - const int _3byteFormats[]={TJPF_RGB, TJPF_BGR}; const int _4byteFormats[]={TJPF_RGBX, TJPF_BGRX, TJPF_XBGR, TJPF_XRGB, TJPF_CMYK}; @@ -196,12 +194,14 @@ int checkBuf(unsigned char *buf, int w, int h, int pf, int subsamp, int roffset=tjRedOffset[pf]; int goffset=tjGreenOffset[pf]; int boffset=tjBlueOffset[pf]; - int aoffset=alphaOffset[pf]; + int aoffset=tjAlphaOffset[pf]; int ps=tjPixelSize[pf]; int index, row, col, retval=1; int halfway=16*sf.num/sf.denom; int blocksize=8*sf.num/sf.denom; + if(pf==TJPF_GRAY) roffset=goffset=boffset=0; + if(pf==TJPF_CMYK) { for(row=0; rowchar pixel[], - * then the red component will be pixel[tjRedOffset[TJ_BGRX]]. + * then the red component will be pixel[tjRedOffset[TJ_BGRX]]. This + * will be -1 if the pixel format does not have a red component. */ -static const int tjRedOffset[TJ_NUMPF] = {0, 2, 0, 2, 3, 1, 0, 0, 2, 3, 1, -1}; +static const int tjRedOffset[TJ_NUMPF] = { + 0, 2, 0, 2, 3, 1, -1, 0, 2, 3, 1, -1 +}; /** * Green offset (in bytes) for a given pixel format. This specifies the number * of bytes that the green component is offset from the start of the pixel. * For instance, if a pixel of format TJ_BGRX is stored in * char pixel[], then the green component will be - * pixel[tjGreenOffset[TJ_BGRX]]. + * pixel[tjGreenOffset[TJ_BGRX]]. This will be -1 if the pixel format + * does not have a green component. */ -static const int tjGreenOffset[TJ_NUMPF] = {1, 1, 1, 1, 2, 2, 0, 1, 1, 2, 2, -1}; +static const int tjGreenOffset[TJ_NUMPF] = { + 1, 1, 1, 1, 2, 2, -1, 1, 1, 2, 2, -1 +}; /** * Blue offset (in bytes) for a given pixel format. This specifies the number * of bytes that the Blue component is offset from the start of the pixel. For * instance, if a pixel of format TJ_BGRX is stored in char pixel[], - * then the blue component will be pixel[tjBlueOffset[TJ_BGRX]]. + * then the blue component will be pixel[tjBlueOffset[TJ_BGRX]]. This + * will be -1 if the pixel format does not have a blue component. + */ +static const int tjBlueOffset[TJ_NUMPF] = { + 2, 0, 2, 0, 1, 3, -1, 2, 0, 1, 3, -1 +}; +/** + * Alpha offset (in bytes) for a given pixel format. This specifies the number + * of bytes that the Alpha component is offset from the start of the pixel. + * For instance, if a pixel of format TJ_BGRA is stored in + * char pixel[], then the alpha component will be + * pixel[tjAlphaOffset[TJ_BGRA]]. This will be -1 if the pixel format + * does not have an alpha component. */ -static const int tjBlueOffset[TJ_NUMPF] = {2, 0, 2, 0, 1, 3, 0, 2, 0, 1, 3, -1}; +static const int tjAlphaOffset[TJ_NUMPF] = { + -1, -1, -1, -1, -1, -1, -1, 3, 3, 0, 0, -1 +}; /** - * Pixel size (in bytes) for a given pixel format. + * Pixel size (in bytes) for a given pixel format */ -static const int tjPixelSize[TJ_NUMPF] = {3, 3, 4, 4, 4, 4, 1, 4, 4, 4, 4, 4}; +static const int tjPixelSize[TJ_NUMPF] = { + 3, 3, 4, 4, 4, 4, 1, 4, 4, 4, 4, 4 +}; /**