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.
This commit is contained in:
10
ChangeLog.md
10
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
|
||||
=====
|
||||
|
||||
@@ -347,6 +347,9 @@ Variables</h2></td></tr>
|
||||
<tr class="memitem:ga84e2e35d3f08025f976ec1ec53693dea"><td class="memItemLeft" align="right" valign="top">static const int </td><td class="memItemRight" valign="bottom"><a class="el" href="group___turbo_j_p_e_g.html#ga84e2e35d3f08025f976ec1ec53693dea">tjBlueOffset</a> [<a class="el" href="group___turbo_j_p_e_g.html#ga7010a4402f54a45ba822ad8675a4655e">TJ_NUMPF</a>]</td></tr>
|
||||
<tr class="memdesc:ga84e2e35d3f08025f976ec1ec53693dea"><td class="mdescLeft"> </td><td class="mdescRight">Blue offset (in bytes) for a given pixel format. <a href="#ga84e2e35d3f08025f976ec1ec53693dea">More...</a><br/></td></tr>
|
||||
<tr class="separator:ga84e2e35d3f08025f976ec1ec53693dea"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:ga5af0ab065feefd526debf1e20c43e837"><td class="memItemLeft" align="right" valign="top">static const int </td><td class="memItemRight" valign="bottom"><a class="el" href="group___turbo_j_p_e_g.html#ga5af0ab065feefd526debf1e20c43e837">tjAlphaOffset</a> [<a class="el" href="group___turbo_j_p_e_g.html#ga7010a4402f54a45ba822ad8675a4655e">TJ_NUMPF</a>]</td></tr>
|
||||
<tr class="memdesc:ga5af0ab065feefd526debf1e20c43e837"><td class="mdescLeft"> </td><td class="mdescRight">Alpha offset (in bytes) for a given pixel format. <a href="#ga5af0ab065feefd526debf1e20c43e837">More...</a><br/></td></tr>
|
||||
<tr class="separator:ga5af0ab065feefd526debf1e20c43e837"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:gad77cf8fe5b2bfd3cb3f53098146abb4c"><td class="memItemLeft" align="right" valign="top">static const int </td><td class="memItemRight" valign="bottom"><a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c">tjPixelSize</a> [<a class="el" href="group___turbo_j_p_e_g.html#ga7010a4402f54a45ba822ad8675a4655e">TJ_NUMPF</a>]</td></tr>
|
||||
<tr class="memdesc:gad77cf8fe5b2bfd3cb3f53098146abb4c"><td class="mdescLeft"> </td><td class="mdescRight">Pixel size (in bytes) for a given pixel format. <a href="#gad77cf8fe5b2bfd3cb3f53098146abb4c">More...</a><br/></td></tr>
|
||||
<tr class="separator:gad77cf8fe5b2bfd3cb3f53098146abb4c"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
@@ -2581,6 +2584,29 @@ If you choose option 1, <code>dstSizes[i]</code> should be set to the size of yo
|
||||
</div>
|
||||
</div>
|
||||
<h2 class="groupheader">Variable Documentation</h2>
|
||||
<a class="anchor" id="ga5af0ab065feefd526debf1e20c43e837"></a>
|
||||
<div class="memitem">
|
||||
<div class="memproto">
|
||||
<table class="mlabels">
|
||||
<tr>
|
||||
<td class="mlabels-left">
|
||||
<table class="memname">
|
||||
<tr>
|
||||
<td class="memname">const int tjAlphaOffset[<a class="el" href="group___turbo_j_p_e_g.html#ga7010a4402f54a45ba822ad8675a4655e">TJ_NUMPF</a>]</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td class="mlabels-right">
|
||||
<span class="mlabels"><span class="mlabel">static</span></span> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
|
||||
<p>Alpha offset (in bytes) for a given pixel format. </p>
|
||||
<p>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 <code>char pixel[]</code>, then the alpha component will be <code>pixel[tjAlphaOffset[TJ_BGRA]]</code>. This will be -1 if the pixel format does not have an alpha component. </p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<a class="anchor" id="ga84e2e35d3f08025f976ec1ec53693dea"></a>
|
||||
<div class="memitem">
|
||||
<div class="memproto">
|
||||
@@ -2600,7 +2626,7 @@ If you choose option 1, <code>dstSizes[i]</code> should be set to the size of yo
|
||||
</div><div class="memdoc">
|
||||
|
||||
<p>Blue offset (in bytes) for a given pixel format. </p>
|
||||
<p>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 <code>char pixel[]</code>, then the blue component will be <code>pixel[tjBlueOffset[TJ_BGRX]]</code>. </p>
|
||||
<p>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 <code>char pixel[]</code>, then the blue component will be <code>pixel[tjBlueOffset[TJ_BGRX]]</code>. This will be -1 if the pixel format does not have a blue component. </p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@@ -2623,7 +2649,7 @@ If you choose option 1, <code>dstSizes[i]</code> should be set to the size of yo
|
||||
</div><div class="memdoc">
|
||||
|
||||
<p>Green offset (in bytes) for a given pixel format. </p>
|
||||
<p>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 <code>char pixel[]</code>, then the green component will be <code>pixel[tjGreenOffset[TJ_BGRX]]</code>. </p>
|
||||
<p>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 <code>char pixel[]</code>, then the green component will be <code>pixel[tjGreenOffset[TJ_BGRX]]</code>. This will be -1 if the pixel format does not have a green component. </p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@@ -2728,7 +2754,7 @@ If you choose option 1, <code>dstSizes[i]</code> should be set to the size of yo
|
||||
</div><div class="memdoc">
|
||||
|
||||
<p>Red offset (in bytes) for a given pixel format. </p>
|
||||
<p>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 <code>char pixel[]</code>, then the red component will be <code>pixel[tjRedOffset[TJ_BGRX]]</code>. </p>
|
||||
<p>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 <code>char pixel[]</code>, then the red component will be <code>pixel[tjRedOffset[TJ_BGRX]]</code>. This will be -1 if the pixel format does not have a red component. </p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -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']]],
|
||||
|
||||
@@ -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']]],
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -7,8 +7,12 @@
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript"><!--
|
||||
if (location.href.indexOf('is-external=true') == -1) {
|
||||
parent.document.title="Constant Field Values";
|
||||
try {
|
||||
if (location.href.indexOf('is-external=true') == -1) {
|
||||
parent.document.title="Constant Field Values";
|
||||
}
|
||||
}
|
||||
catch(err) {
|
||||
}
|
||||
//-->
|
||||
</script>
|
||||
|
||||
@@ -7,8 +7,12 @@
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript"><!--
|
||||
if (location.href.indexOf('is-external=true') == -1) {
|
||||
parent.document.title="Deprecated List";
|
||||
try {
|
||||
if (location.href.indexOf('is-external=true') == -1) {
|
||||
parent.document.title="Deprecated List";
|
||||
}
|
||||
}
|
||||
catch(err) {
|
||||
}
|
||||
//-->
|
||||
</script>
|
||||
|
||||
@@ -7,8 +7,12 @@
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript"><!--
|
||||
if (location.href.indexOf('is-external=true') == -1) {
|
||||
parent.document.title="API Help";
|
||||
try {
|
||||
if (location.href.indexOf('is-external=true') == -1) {
|
||||
parent.document.title="API Help";
|
||||
}
|
||||
}
|
||||
catch(err) {
|
||||
}
|
||||
//-->
|
||||
</script>
|
||||
|
||||
@@ -7,8 +7,12 @@
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript"><!--
|
||||
if (location.href.indexOf('is-external=true') == -1) {
|
||||
parent.document.title="Index";
|
||||
try {
|
||||
if (location.href.indexOf('is-external=true') == -1) {
|
||||
parent.document.title="Index";
|
||||
}
|
||||
}
|
||||
catch(err) {
|
||||
}
|
||||
//-->
|
||||
</script>
|
||||
@@ -349,6 +353,11 @@
|
||||
</a>
|
||||
<h2 class="title">G</h2>
|
||||
<dl>
|
||||
<dt><span class="strong"><a href="./org/libjpegturbo/turbojpeg/TJ.html#getAlphaOffset(int)">getAlphaOffset(int)</a></span> - Static method in class org.libjpegturbo.turbojpeg.<a href="./org/libjpegturbo/turbojpeg/TJ.html" title="class in org.libjpegturbo.turbojpeg">TJ</a></dt>
|
||||
<dd>
|
||||
<div class="block">For the given pixel format, returns the number of bytes that the alpha
|
||||
component is offset from the start of the pixel.</div>
|
||||
</dd>
|
||||
<dt><span class="strong"><a href="./org/libjpegturbo/turbojpeg/TJ.html#getBlueOffset(int)">getBlueOffset(int)</a></span> - Static method in class org.libjpegturbo.turbojpeg.<a href="./org/libjpegturbo/turbojpeg/TJ.html" title="class in org.libjpegturbo.turbojpeg">TJ</a></dt>
|
||||
<dd>
|
||||
<div class="block">For the given pixel format, returns the number of bytes that the blue
|
||||
|
||||
@@ -4,11 +4,12 @@
|
||||
<head>
|
||||
<title>Generated Documentation (Untitled)</title>
|
||||
<script type="text/javascript">
|
||||
targetPage = "" + window.location.search;
|
||||
if (targetPage != "" && targetPage != "undefined")
|
||||
targetPage = targetPage.substring(1);
|
||||
if (targetPage.indexOf(":") != -1 || (targetPage != "" && !validURL(targetPage)))
|
||||
targetPage = "undefined";
|
||||
tmpTargetPage = "" + window.location.search;
|
||||
if (tmpTargetPage != "" && tmpTargetPage != "undefined")
|
||||
tmpTargetPage = tmpTargetPage.substring(1);
|
||||
if (tmpTargetPage.indexOf(":") != -1 || (tmpTargetPage != "" && !validURL(tmpTargetPage)))
|
||||
tmpTargetPage = "undefined";
|
||||
targetPage = tmpTargetPage;
|
||||
function validURL(url) {
|
||||
try {
|
||||
url = decodeURIComponent(url);
|
||||
|
||||
@@ -7,8 +7,12 @@
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript"><!--
|
||||
if (location.href.indexOf('is-external=true') == -1) {
|
||||
parent.document.title="TJ";
|
||||
try {
|
||||
if (location.href.indexOf('is-external=true') == -1) {
|
||||
parent.document.title="TJ";
|
||||
}
|
||||
}
|
||||
catch(err) {
|
||||
}
|
||||
//-->
|
||||
</script>
|
||||
@@ -417,53 +421,60 @@ extends java.lang.Object</pre>
|
||||
</tr>
|
||||
<tr class="rowColor">
|
||||
<td class="colFirst"><code>static int</code></td>
|
||||
<td class="colLast"><code><strong><a href="../../../org/libjpegturbo/turbojpeg/TJ.html#getAlphaOffset(int)">getAlphaOffset</a></strong>(int pixelFormat)</code>
|
||||
<div class="block">For the given pixel format, returns the number of bytes that the alpha
|
||||
component is offset from the start of the pixel.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="altColor">
|
||||
<td class="colFirst"><code>static int</code></td>
|
||||
<td class="colLast"><code><strong><a href="../../../org/libjpegturbo/turbojpeg/TJ.html#getBlueOffset(int)">getBlueOffset</a></strong>(int pixelFormat)</code>
|
||||
<div class="block">For the given pixel format, returns the number of bytes that the blue
|
||||
component is offset from the start of the pixel.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="altColor">
|
||||
<tr class="rowColor">
|
||||
<td class="colFirst"><code>static int</code></td>
|
||||
<td class="colLast"><code><strong><a href="../../../org/libjpegturbo/turbojpeg/TJ.html#getGreenOffset(int)">getGreenOffset</a></strong>(int pixelFormat)</code>
|
||||
<div class="block">For the given pixel format, returns the number of bytes that the green
|
||||
component is offset from the start of the pixel.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="rowColor">
|
||||
<tr class="altColor">
|
||||
<td class="colFirst"><code>static int</code></td>
|
||||
<td class="colLast"><code><strong><a href="../../../org/libjpegturbo/turbojpeg/TJ.html#getMCUHeight(int)">getMCUHeight</a></strong>(int subsamp)</code>
|
||||
<div class="block">Returns the MCU block height for the given level of chrominance
|
||||
subsampling.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="altColor">
|
||||
<tr class="rowColor">
|
||||
<td class="colFirst"><code>static int</code></td>
|
||||
<td class="colLast"><code><strong><a href="../../../org/libjpegturbo/turbojpeg/TJ.html#getMCUWidth(int)">getMCUWidth</a></strong>(int subsamp)</code>
|
||||
<div class="block">Returns the MCU block width for the given level of chrominance
|
||||
subsampling.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="rowColor">
|
||||
<tr class="altColor">
|
||||
<td class="colFirst"><code>static int</code></td>
|
||||
<td class="colLast"><code><strong><a href="../../../org/libjpegturbo/turbojpeg/TJ.html#getPixelSize(int)">getPixelSize</a></strong>(int pixelFormat)</code>
|
||||
<div class="block">Returns the pixel size (in bytes) for the given pixel format.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="altColor">
|
||||
<tr class="rowColor">
|
||||
<td class="colFirst"><code>static int</code></td>
|
||||
<td class="colLast"><code><strong><a href="../../../org/libjpegturbo/turbojpeg/TJ.html#getRedOffset(int)">getRedOffset</a></strong>(int pixelFormat)</code>
|
||||
<div class="block">For the given pixel format, returns the number of bytes that the red
|
||||
component is offset from the start of the pixel.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="rowColor">
|
||||
<tr class="altColor">
|
||||
<td class="colFirst"><code>static <a href="../../../org/libjpegturbo/turbojpeg/TJScalingFactor.html" title="class in org.libjpegturbo.turbojpeg">TJScalingFactor</a>[]</code></td>
|
||||
<td class="colLast"><code><strong><a href="../../../org/libjpegturbo/turbojpeg/TJ.html#getScalingFactors()">getScalingFactors</a></strong>()</code>
|
||||
<div class="block">Returns a list of fractional scaling factors that the JPEG decompressor in
|
||||
this implementation of TurboJPEG supports.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="altColor">
|
||||
<tr class="rowColor">
|
||||
<td class="colFirst"><code>static int</code></td>
|
||||
<td class="colLast"><code><strong><a href="../../../org/libjpegturbo/turbojpeg/TJ.html#planeHeight(int,%20int,%20int)">planeHeight</a></strong>(int componentID,
|
||||
int height,
|
||||
@@ -471,7 +482,7 @@ extends java.lang.Object</pre>
|
||||
<div class="block">Returns the plane height of a YUV image plane with the given parameters.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="rowColor">
|
||||
<tr class="altColor">
|
||||
<td class="colFirst"><code>static int</code></td>
|
||||
<td class="colLast"><code><strong><a href="../../../org/libjpegturbo/turbojpeg/TJ.html#planeSizeYUV(int,%20int,%20int,%20int,%20int)">planeSizeYUV</a></strong>(int componentID,
|
||||
int width,
|
||||
@@ -482,7 +493,7 @@ extends java.lang.Object</pre>
|
||||
plane with the given parameters.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="altColor">
|
||||
<tr class="rowColor">
|
||||
<td class="colFirst"><code>static int</code></td>
|
||||
<td class="colLast"><code><strong><a href="../../../org/libjpegturbo/turbojpeg/TJ.html#planeWidth(int,%20int,%20int)">planeWidth</a></strong>(int componentID,
|
||||
int width,
|
||||
@@ -1137,7 +1148,8 @@ public static final int FLAG_FORCESSE3</pre>
|
||||
then the red component will be
|
||||
<code>pixel[TJ.getRedOffset(TJ.PF_BGRX)]</code>.</div>
|
||||
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>pixelFormat</code> - the pixel format (one of <code>PF_*</code>)</dd>
|
||||
<dt><span class="strong">Returns:</span></dt><dd>the red offset for the given pixel format.</dd></dl>
|
||||
<dt><span class="strong">Returns:</span></dt><dd>the red offset for the given pixel format, or -1 if the pixel
|
||||
format does not have a red component.</dd></dl>
|
||||
</li>
|
||||
</ul>
|
||||
<a name="getGreenOffset(int)">
|
||||
@@ -1153,7 +1165,8 @@ public static final int FLAG_FORCESSE3</pre>
|
||||
then the green component will be
|
||||
<code>pixel[TJ.getGreenOffset(TJ.PF_BGRX)]</code>.</div>
|
||||
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>pixelFormat</code> - the pixel format (one of <code>PF_*</code>)</dd>
|
||||
<dt><span class="strong">Returns:</span></dt><dd>the green offset for the given pixel format.</dd></dl>
|
||||
<dt><span class="strong">Returns:</span></dt><dd>the green offset for the given pixel format, or -1 if the pixel
|
||||
format does not have a green component.</dd></dl>
|
||||
</li>
|
||||
</ul>
|
||||
<a name="getBlueOffset(int)">
|
||||
@@ -1169,7 +1182,25 @@ public static final int FLAG_FORCESSE3</pre>
|
||||
then the blue component will be
|
||||
<code>pixel[TJ.getBlueOffset(TJ.PF_BGRX)]</code>.</div>
|
||||
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>pixelFormat</code> - the pixel format (one of <code>PF_*</code>)</dd>
|
||||
<dt><span class="strong">Returns:</span></dt><dd>the blue offset for the given pixel format.</dd></dl>
|
||||
<dt><span class="strong">Returns:</span></dt><dd>the blue offset for the given pixel format, or -1 if the pixel
|
||||
format does not have a blue component.</dd></dl>
|
||||
</li>
|
||||
</ul>
|
||||
<a name="getAlphaOffset(int)">
|
||||
<!-- -->
|
||||
</a>
|
||||
<ul class="blockList">
|
||||
<li class="blockList">
|
||||
<h4>getAlphaOffset</h4>
|
||||
<pre>public static int getAlphaOffset(int pixelFormat)</pre>
|
||||
<div class="block">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 <code>TJ.PF_BGRA</code> is stored in <code>char pixel[]</code>,
|
||||
then the alpha component will be
|
||||
<code>pixel[TJ.getAlphaOffset(TJ.PF_BGRA)]</code>.</div>
|
||||
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>pixelFormat</code> - the pixel format (one of <code>PF_*</code>)</dd>
|
||||
<dt><span class="strong">Returns:</span></dt><dd>the alpha offset for the given pixel format, or -1 if the pixel
|
||||
format does not have a alpha component.</dd></dl>
|
||||
</li>
|
||||
</ul>
|
||||
<a name="bufSize(int, int, int)">
|
||||
|
||||
@@ -7,8 +7,12 @@
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript"><!--
|
||||
if (location.href.indexOf('is-external=true') == -1) {
|
||||
parent.document.title="TJCompressor";
|
||||
try {
|
||||
if (location.href.indexOf('is-external=true') == -1) {
|
||||
parent.document.title="TJCompressor";
|
||||
}
|
||||
}
|
||||
catch(err) {
|
||||
}
|
||||
//-->
|
||||
</script>
|
||||
|
||||
@@ -7,8 +7,12 @@
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript"><!--
|
||||
if (location.href.indexOf('is-external=true') == -1) {
|
||||
parent.document.title="TJCustomFilter";
|
||||
try {
|
||||
if (location.href.indexOf('is-external=true') == -1) {
|
||||
parent.document.title="TJCustomFilter";
|
||||
}
|
||||
}
|
||||
catch(err) {
|
||||
}
|
||||
//-->
|
||||
</script>
|
||||
|
||||
@@ -7,8 +7,12 @@
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript"><!--
|
||||
if (location.href.indexOf('is-external=true') == -1) {
|
||||
parent.document.title="TJDecompressor";
|
||||
try {
|
||||
if (location.href.indexOf('is-external=true') == -1) {
|
||||
parent.document.title="TJDecompressor";
|
||||
}
|
||||
}
|
||||
catch(err) {
|
||||
}
|
||||
//-->
|
||||
</script>
|
||||
|
||||
@@ -7,8 +7,12 @@
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript"><!--
|
||||
if (location.href.indexOf('is-external=true') == -1) {
|
||||
parent.document.title="TJException";
|
||||
try {
|
||||
if (location.href.indexOf('is-external=true') == -1) {
|
||||
parent.document.title="TJException";
|
||||
}
|
||||
}
|
||||
catch(err) {
|
||||
}
|
||||
//-->
|
||||
</script>
|
||||
|
||||
@@ -7,8 +7,12 @@
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript"><!--
|
||||
if (location.href.indexOf('is-external=true') == -1) {
|
||||
parent.document.title="TJScalingFactor";
|
||||
try {
|
||||
if (location.href.indexOf('is-external=true') == -1) {
|
||||
parent.document.title="TJScalingFactor";
|
||||
}
|
||||
}
|
||||
catch(err) {
|
||||
}
|
||||
//-->
|
||||
</script>
|
||||
|
||||
@@ -7,8 +7,12 @@
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript"><!--
|
||||
if (location.href.indexOf('is-external=true') == -1) {
|
||||
parent.document.title="TJTransform";
|
||||
try {
|
||||
if (location.href.indexOf('is-external=true') == -1) {
|
||||
parent.document.title="TJTransform";
|
||||
}
|
||||
}
|
||||
catch(err) {
|
||||
}
|
||||
//-->
|
||||
</script>
|
||||
|
||||
@@ -7,8 +7,12 @@
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript"><!--
|
||||
if (location.href.indexOf('is-external=true') == -1) {
|
||||
parent.document.title="TJTransformer";
|
||||
try {
|
||||
if (location.href.indexOf('is-external=true') == -1) {
|
||||
parent.document.title="TJTransformer";
|
||||
}
|
||||
}
|
||||
catch(err) {
|
||||
}
|
||||
//-->
|
||||
</script>
|
||||
|
||||
@@ -7,8 +7,12 @@
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript"><!--
|
||||
if (location.href.indexOf('is-external=true') == -1) {
|
||||
parent.document.title="YUVImage";
|
||||
try {
|
||||
if (location.href.indexOf('is-external=true') == -1) {
|
||||
parent.document.title="YUVImage";
|
||||
}
|
||||
}
|
||||
catch(err) {
|
||||
}
|
||||
//-->
|
||||
</script>
|
||||
|
||||
@@ -7,8 +7,12 @@
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript"><!--
|
||||
if (location.href.indexOf('is-external=true') == -1) {
|
||||
parent.document.title="org.libjpegturbo.turbojpeg";
|
||||
try {
|
||||
if (location.href.indexOf('is-external=true') == -1) {
|
||||
parent.document.title="org.libjpegturbo.turbojpeg";
|
||||
}
|
||||
}
|
||||
catch(err) {
|
||||
}
|
||||
//-->
|
||||
</script>
|
||||
|
||||
@@ -7,8 +7,12 @@
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript"><!--
|
||||
if (location.href.indexOf('is-external=true') == -1) {
|
||||
parent.document.title="org.libjpegturbo.turbojpeg Class Hierarchy";
|
||||
try {
|
||||
if (location.href.indexOf('is-external=true') == -1) {
|
||||
parent.document.title="org.libjpegturbo.turbojpeg Class Hierarchy";
|
||||
}
|
||||
}
|
||||
catch(err) {
|
||||
}
|
||||
//-->
|
||||
</script>
|
||||
|
||||
@@ -7,8 +7,12 @@
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript"><!--
|
||||
if (location.href.indexOf('is-external=true') == -1) {
|
||||
parent.document.title="Class Hierarchy";
|
||||
try {
|
||||
if (location.href.indexOf('is-external=true') == -1) {
|
||||
parent.document.title="Class Hierarchy";
|
||||
}
|
||||
}
|
||||
catch(err) {
|
||||
}
|
||||
//-->
|
||||
</script>
|
||||
|
||||
@@ -7,8 +7,12 @@
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript"><!--
|
||||
if (location.href.indexOf('is-external=true') == -1) {
|
||||
parent.document.title="Serialized Form";
|
||||
try {
|
||||
if (location.href.indexOf('is-external=true') == -1) {
|
||||
parent.document.title="Serialized Form";
|
||||
}
|
||||
}
|
||||
catch(err) {
|
||||
}
|
||||
//-->
|
||||
</script>
|
||||
|
||||
@@ -235,7 +235,8 @@ public final class TJ {
|
||||
*
|
||||
* @param pixelFormat the pixel format (one of <code>PF_*</code>)
|
||||
*
|
||||
* @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 <code>PF_*</code>)
|
||||
*
|
||||
* @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 <code>PF_*</code>)
|
||||
*
|
||||
* @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 <code>TJ.PF_BGRA</code> is stored in <code>char pixel[]</code>,
|
||||
* then the alpha component will be
|
||||
* <code>pixel[TJ.getAlphaOffset(TJ.PF_BGRA)]</code>.
|
||||
*
|
||||
* @param pixelFormat the pixel format (one of <code>PF_*</code>)
|
||||
*
|
||||
* @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
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -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; row<h; row++)
|
||||
@@ -738,7 +738,7 @@ int cmpBitmap(unsigned char *buf, int width, int pitch, int height, int pf,
|
||||
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 i, j;
|
||||
|
||||
|
||||
39
turbojpeg.h
39
turbojpeg.h
@@ -256,33 +256,54 @@ enum TJPF
|
||||
TJPF_UNKNOWN = -1
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* 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 <tt>char pixel[]</tt>,
|
||||
* then the red component will be <tt>pixel[tjRedOffset[TJ_BGRX]]</tt>.
|
||||
* then the red component will be <tt>pixel[tjRedOffset[TJ_BGRX]]</tt>. 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
|
||||
* <tt>char pixel[]</tt>, then the green component will be
|
||||
* <tt>pixel[tjGreenOffset[TJ_BGRX]]</tt>.
|
||||
* <tt>pixel[tjGreenOffset[TJ_BGRX]]</tt>. 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 <tt>char pixel[]</tt>,
|
||||
* then the blue component will be <tt>pixel[tjBlueOffset[TJ_BGRX]]</tt>.
|
||||
* then the blue component will be <tt>pixel[tjBlueOffset[TJ_BGRX]]</tt>. 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, 0, 2, 0, 1, 3, -1};
|
||||
static const int tjBlueOffset[TJ_NUMPF] = {
|
||||
2, 0, 2, 0, 1, 3, -1, 2, 0, 1, 3, -1
|
||||
};
|
||||
/**
|
||||
* Pixel size (in bytes) for a given pixel format.
|
||||
* 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
|
||||
* <tt>char pixel[]</tt>, then the alpha component will be
|
||||
* <tt>pixel[tjAlphaOffset[TJ_BGRA]]</tt>. This will be -1 if the pixel format
|
||||
* does not have an alpha component.
|
||||
*/
|
||||
static const int tjPixelSize[TJ_NUMPF] = {3, 3, 4, 4, 4, 4, 1, 4, 4, 4, 4, 4};
|
||||
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
|
||||
*/
|
||||
static const int tjPixelSize[TJ_NUMPF] = {
|
||||
3, 3, 4, 4, 4, 4, 1, 4, 4, 4, 4, 4
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user