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:
@@ -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
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user