aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/glu/mipmap/ScaleInternal.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/glu/mipmap/ScaleInternal.java')
-rw-r--r--src/jogl/classes/jogamp/opengl/glu/mipmap/ScaleInternal.java364
1 files changed, 182 insertions, 182 deletions
diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/ScaleInternal.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/ScaleInternal.java
index 9c95ae304..9aca1fb03 100644
--- a/src/jogl/classes/jogamp/opengl/glu/mipmap/ScaleInternal.java
+++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/ScaleInternal.java
@@ -6,15 +6,15 @@
* this file except in compliance with the License. You may obtain a copy
* of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
* Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
- *
+ *
* http://oss.sgi.com/projects/FreeB
- *
+ *
* Note that, as provided in the License, the Software is distributed on an
* "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
* DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
* CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
* PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
- *
+ *
* NOTE: The Original Code (as defined below) has been licensed to Sun
* Microsystems, Inc. ("Sun") under the SGI Free Software License B
* (Version 1.1), shown above ("SGI License"). Pursuant to Section
@@ -30,7 +30,7 @@
* Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
* Copyright in any portions created by third parties is as indicated
* elsewhere herein. All Rights Reserved.
- *
+ *
* Additional Notice Provisions: The application programming interfaces
* established by SGI in conjunction with the Original Code are The
* OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
@@ -55,9 +55,9 @@ import com.jogamp.common.nio.Buffers;
* @author Administrator
*/
public class ScaleInternal {
-
+
public static final float UINT_MAX = (float)(0x00000000FFFFFFFF);
-
+
public static void scale_internal( int components, int widthin, int heightin,
ShortBuffer datain, int widthout, int heightout, ShortBuffer dataout ) {
float x, lowx, highx, convx, halfconvx;
@@ -69,7 +69,7 @@ public class ScaleInternal {
float area;
int i, j, k, yint, xint, xindex, yindex;
int temp;
-
+
if( (widthin == (widthout * 2)) && (heightin == (heightout * 2)) ) {
HalveImage.halveImage( components, widthin, heightin, datain, dataout );
return;
@@ -101,7 +101,7 @@ public class ScaleInternal {
// data.
totals[0] = totals[1] = totals[2] = totals[3] = 0.0f;
area = 0.0f;
-
+
y = lowy;
yint = (int)Math.floor( y );
while( y < highy ) {
@@ -111,10 +111,10 @@ public class ScaleInternal {
} else {
ypercent = yint + 1 - y;
}
-
+
x = lowx;
xint = (int)Math.floor( x );
-
+
while( x < highx ) {
xindex = ( xint + widthin ) % widthin;
if( highx < xint + 1 ) {
@@ -122,21 +122,21 @@ public class ScaleInternal {
} else {
xpercent = xint + 1 - x;
}
-
+
percent = xpercent * ypercent;
area += percent;
temp = ( xindex + ( yindex * widthin) ) * components;
for( k = 0; k < components; k++ ) {
- totals[k] += datain.get( temp + k ) * percent;
+ totals[k] += datain.get( temp + k ) * percent;
}
-
+
xint++;
x = xint;
}
yint++;
y = yint;
}
-
+
temp = ( j + ( i * widthout ) ) * components;
for( k = 0; k < components; k++ ) {
// totals[] should be rounded in the case of enlarging an RGB
@@ -146,9 +146,9 @@ public class ScaleInternal {
}
}
}
-
+
public static void scale_internal_ubyte( int components, int widthin, int heightin,
- ByteBuffer datain, int widthout, int heightout,
+ ByteBuffer datain, int widthout, int heightout,
ByteBuffer dataout, int element_size, int ysize, int group_size ) {
float x, convx;
float y, convy;
@@ -157,11 +157,11 @@ public class ScaleInternal {
float[] totals = new float[4];
float area;
int i, j, k, xindex;
-
+
int temp, temp0;
int temp_index;
int outindex;
-
+
int lowx_int, highx_int, lowy_int, highy_int;
float x_percent, y_percent;
float lowx_float, highx_float, lowy_float, highy_float;
@@ -169,9 +169,9 @@ public class ScaleInternal {
int convy_int, convx_int;
int l, m;
int left, right;
-
+
if( (widthin == (widthout * 2)) && (heightin == (heightout * 2)) ) {
- HalveImage.halveImage_ubyte( components, widthin, heightin, datain, dataout,
+ HalveImage.halveImage_ubyte( components, widthin, heightin, datain, dataout,
element_size, ysize, group_size );
return;
}
@@ -181,14 +181,14 @@ public class ScaleInternal {
convy_float = convy - convy_int;
convx_int = (int)Math.floor( convx );
convx_float = convx - convx_int;
-
+
area = convx * convy;
-
+
lowy_int = 0;
lowy_float = 0.0f;
highy_int = convy_int;
highy_float = convy_float;
-
+
for( i = 0; i < heightout; i++ ) {
// Clamp here to be sure we don't read beyond input buffer.
if (highy_int >= heightin)
@@ -204,19 +204,19 @@ public class ScaleInternal {
highx_int = convx_int;
highx_float = convx_float;
}
-
+
for( j = 0; j < widthout; j++ ) {
-
+
// Ok, now apply box filter to box that goes from (lowx, lowy)
// to (highx, highy) on input data into this pixel on output
// data.
totals[0] = totals[1] = totals[2] = totals[3] = 0.0f;
-
+
// caulate the value for pixels in the 1st row
xindex = lowx_int * group_size;
if( ( highy_int > lowy_int ) && ( highx_int > lowx_int ) ) {
-
+
y_percent = 1 - lowy_float;
temp = xindex + lowy_int * ysize;
percent = y_percent * ( 1 - lowx_float );
@@ -239,7 +239,7 @@ public class ScaleInternal {
datain.position( temp_index );
totals[k] += ( 0x000000FF & datain.get() ) * percent;
}
-
+
// calculate the value for pixels in the last row
y_percent = highy_float;
percent = y_percent * ( 1 - lowx_float );
@@ -261,7 +261,7 @@ public class ScaleInternal {
datain.position( temp_index );
totals[k] += ( 0x000000FF & datain.get() ) * percent;
}
-
+
// calculate the value for the pixels in the 1st and last column
for( m = lowy_int + 1; m < highy_int; m++ ) {
left += ysize;
@@ -339,7 +339,7 @@ public class ScaleInternal {
}
temp0 += ysize;
}
-
+
outindex = ( j + ( i * widthout ) ) * components;
for( k = 0; k < components; k++ ) {
dataout.position( outindex + k );
@@ -371,9 +371,9 @@ public class ScaleInternal {
}
}
}
-
+
public static void scale_internal_byte( int components, int widthin, int heightin,
- ByteBuffer datain, int widthout, int heightout,
+ ByteBuffer datain, int widthout, int heightout,
ByteBuffer dataout, int element_size, int ysize,
int group_size ) {
float x, convx;
@@ -383,11 +383,11 @@ public class ScaleInternal {
float[] totals = new float[4];
float area;
int i, j, k, xindex;
-
+
int temp, temp0;
int temp_index;
int outindex;
-
+
int lowx_int, highx_int, lowy_int, highy_int;
float x_percent, y_percent;
float lowx_float, highx_float, lowy_float, highy_float;
@@ -395,9 +395,9 @@ public class ScaleInternal {
int convy_int, convx_int;
int l, m;
int left, right;
-
+
if( (widthin == (widthout * 2)) && (heightin == (heightout * 2)) ) {
- HalveImage.halveImage_byte( components, widthin, heightin, datain, dataout,
+ HalveImage.halveImage_byte( components, widthin, heightin, datain, dataout,
element_size, ysize, group_size );
return;
}
@@ -407,14 +407,14 @@ public class ScaleInternal {
convy_float = convy - convy_int;
convx_int = (int)Math.floor( convx );
convx_float = convx - convx_int;
-
+
area = convx * convy;
-
+
lowy_int = 0;
lowy_float = 0.0f;
highy_int = convy_int;
highy_float = convy_float;
-
+
for( i = 0; i < heightout; i++ ) {
// Clamp here to be sure we don't read beyond input buffer.
if (highy_int >= heightin)
@@ -430,18 +430,18 @@ public class ScaleInternal {
highx_int = convx_int;
highx_float = convx_float;
}
-
+
for( j = 0; j < widthout; j++ ) {
-
+
// Ok, now apply box filter to box that goes from (lowx, lowy)
// to (highx, highy) on input data into this pixel on output
// data.
totals[0] = totals[1] = totals[2] = totals[3] = 0.0f;
-
+
// caulate the value for pixels in the 1st row
xindex = lowx_int * group_size;
if( ( highy_int > lowy_int ) && ( highx_int > lowx_int ) ) {
-
+
y_percent = 1 - lowy_float;
temp = xindex + lowy_int * ysize;
percent = y_percent * ( 1 - lowx_float );
@@ -464,7 +464,7 @@ public class ScaleInternal {
datain.position( temp_index );
totals[k] += datain.get() * percent;
}
-
+
// calculate the value for pixels in the last row
y_percent = highy_float;
percent = y_percent * ( 1 - lowx_float );
@@ -486,7 +486,7 @@ public class ScaleInternal {
datain.position( temp_index );
totals[k] += datain.get() * percent;
}
-
+
// calculate the value for the pixels in the 1st and last column
for( m = lowy_int + 1; m < highy_int; m++ ) {
left += ysize;
@@ -550,7 +550,7 @@ public class ScaleInternal {
totals[k] += datain.get() * percent;
}
}
-
+
// this is for the pixels in the body
temp0 = xindex + group_size + ( lowy_int + 1 ) * ysize;
for( m = lowy_int + 1; m < highy_int; m++ ) {
@@ -564,7 +564,7 @@ public class ScaleInternal {
}
temp0 += ysize;
}
-
+
outindex = ( j + ( i * widthout ) ) * components;
for( k = 0; k < components; k++ ) {
dataout.position( outindex + k );
@@ -596,10 +596,10 @@ public class ScaleInternal {
}
}
}
-
+
public static void scale_internal_ushort( int components, int widthin, int heightin,
- ByteBuffer datain, int widthout, int heightout,
- ShortBuffer dataout, int element_size, int ysize,
+ ByteBuffer datain, int widthout, int heightout,
+ ShortBuffer dataout, int element_size, int ysize,
int group_size, boolean myswap_bytes ) {
float x, convx;
float y, convy;
@@ -608,11 +608,11 @@ public class ScaleInternal {
float[] totals = new float[4];
float area;
int i, j, k, xindex;
-
+
int temp, temp0;
int temp_index;
int outindex;
-
+
int lowx_int, highx_int, lowy_int, highy_int;
float x_percent, y_percent;
float lowx_float, highx_float, lowy_float, highy_float;
@@ -620,9 +620,9 @@ public class ScaleInternal {
int convy_int, convx_int;
int l, m;
int left, right;
-
+
if( (widthin == (widthout * 2)) && (heightin == (heightout * 2)) ) {
- HalveImage.halveImage_ushort( components, widthin, heightin, datain, dataout,
+ HalveImage.halveImage_ushort( components, widthin, heightin, datain, dataout,
element_size, ysize, group_size, myswap_bytes );
return;
}
@@ -632,14 +632,14 @@ public class ScaleInternal {
convy_float = convy - convy_int;
convx_int = (int)Math.floor( convx );
convx_float = convx - convx_int;
-
+
area = convx * convy;
-
+
lowy_int = 0;
lowy_float = 0.0f;
highy_int = convy_int;
highy_float = convy_float;
-
+
for( i = 0; i < heightout; i++ ) {
// Clamp here to be sure we don't read beyond input buffer.
if (highy_int >= heightin)
@@ -655,18 +655,18 @@ public class ScaleInternal {
highx_int = convx_int;
highx_float = convx_float;
}
-
+
for( j = 0; j < widthout; j++ ) {
-
+
// Ok, now apply box filter to box that goes from (lowx, lowy)
// to (highx, highy) on input data into this pixel on output
// data.
totals[0] = totals[1] = totals[2] = totals[3] = 0.0f;
-
+
// caulate the value for pixels in the 1st row
xindex = lowx_int * group_size;
if( ( highy_int > lowy_int ) && ( highx_int > lowx_int ) ) {
-
+
y_percent = 1 - lowy_float;
temp = xindex + lowy_int * ysize;
percent = y_percent * ( 1 - lowx_float );
@@ -701,7 +701,7 @@ public class ScaleInternal {
totals[k] += ( 0x0000FFFF & datain.getShort()) * percent;
}
}
-
+
// calculate the value for pixels in the last row
y_percent = highy_float;
percent = y_percent * ( 1 - lowx_float );
@@ -735,7 +735,7 @@ public class ScaleInternal {
totals[k] += ( 0x0000FFFF & datain.getShort()) * percent;
}
}
-
+
// calculate the value for the pixels in the 1st and last column
for( m = lowy_int + 1; m < highy_int; m++ ) {
left += ysize;
@@ -834,7 +834,7 @@ public class ScaleInternal {
}
}
}
-
+
// this is for the pixels in the body
temp0 = xindex + group_size + ( lowy_int + 1 ) * ysize;
for( m = lowy_int + 1; m < highy_int; m++ ) {
@@ -852,7 +852,7 @@ public class ScaleInternal {
}
temp0 += ysize;
}
-
+
outindex = ( j + ( i * widthout ) ) * components;
for( k = 0; k < components; k++ ) {
dataout.position( outindex + k );
@@ -884,10 +884,10 @@ public class ScaleInternal {
}
}
}
-
+
public static void scale_internal_short( int components, int widthin, int heightin,
ByteBuffer datain, int widthout, int heightout,
- ShortBuffer dataout, int element_size, int ysize,
+ ShortBuffer dataout, int element_size, int ysize,
int group_size, boolean myswap_bytes ) {
float x, convx;
float y, convy;
@@ -896,11 +896,11 @@ public class ScaleInternal {
float[] totals = new float[4];
float area;
int i, j, k, xindex;
-
+
int temp, temp0;
int temp_index;
int outindex;
-
+
int lowx_int, highx_int, lowy_int, highy_int;
float x_percent, y_percent;
float lowx_float, highx_float, lowy_float, highy_float;
@@ -908,11 +908,11 @@ public class ScaleInternal {
int convy_int, convx_int;
int l, m;
int left, right;
-
+
int swapbuf; // unsigned buffer
-
+
if( (widthin == (widthout * 2)) && (heightin == (heightout * 2)) ) {
- HalveImage.halveImage_short( components, widthin, heightin, datain, dataout,
+ HalveImage.halveImage_short( components, widthin, heightin, datain, dataout,
element_size, ysize, group_size, myswap_bytes );
return;
}
@@ -922,14 +922,14 @@ public class ScaleInternal {
convy_float = convy - convy_int;
convx_int = (int)Math.floor( convx );
convx_float = convx - convx_int;
-
+
area = convx * convy;
-
+
lowy_int = 0;
lowy_float = 0.0f;
highy_int = convy_int;
highy_float = convy_float;
-
+
for( i = 0; i < heightout; i++ ) {
// Clamp here to be sure we don't read beyond input buffer.
if (highy_int >= heightin)
@@ -945,18 +945,18 @@ public class ScaleInternal {
highx_int = convx_int;
highx_float = convx_float;
}
-
+
for( j = 0; j < widthout; j++ ) {
-
+
// Ok, now apply box filter to box that goes from (lowx, lowy)
// to (highx, highy) on input data into this pixel on output
// data.
totals[0] = totals[1] = totals[2] = totals[3] = 0.0f;
-
+
// caulate the value for pixels in the 1st row
xindex = lowx_int * group_size;
if( ( highy_int > lowy_int ) && ( highx_int > lowx_int ) ) {
-
+
y_percent = 1 - lowy_float;
temp = xindex + lowy_int * ysize;
percent = y_percent * ( 1 - lowx_float );
@@ -994,7 +994,7 @@ public class ScaleInternal {
totals[k] += datain.getShort() * percent;
}
}
-
+
// calculate the value for pixels in the last row
y_percent = highy_float;
percent = y_percent * ( 1 - lowx_float );
@@ -1031,7 +1031,7 @@ public class ScaleInternal {
totals[k] += datain.getShort() * percent;
}
}
-
+
// calculate the value for the pixels in the 1st and last column
for( m = lowy_int + 1; m < highy_int; m++ ) {
left += ysize;
@@ -1137,7 +1137,7 @@ public class ScaleInternal {
}
}
}
-
+
// this is for the pixels in the body
temp0 = xindex + group_size + ( lowy_int + 1 ) * ysize;
for( m = lowy_int + 1; m < highy_int; m++ ) {
@@ -1156,7 +1156,7 @@ public class ScaleInternal {
}
temp0 += ysize;
}
-
+
outindex = ( j + ( i * widthout ) ) * components;
for( k = 0; k < components; k++ ) {
dataout.position( outindex + k );
@@ -1188,10 +1188,10 @@ public class ScaleInternal {
}
}
}
-
+
public static void scale_internal_uint( int components, int widthin, int heightin,
- ByteBuffer datain, int widthout, int heightout,
- IntBuffer dataout, int element_size, int ysize,
+ ByteBuffer datain, int widthout, int heightout,
+ IntBuffer dataout, int element_size, int ysize,
int group_size, boolean myswap_bytes ) {
float x, convx;
float y, convy;
@@ -1200,11 +1200,11 @@ public class ScaleInternal {
float[] totals = new float[4];
float area;
int i, j, k, xindex;
-
+
int temp, temp0;
int temp_index;
int outindex;
-
+
int lowx_int, highx_int, lowy_int, highy_int;
float x_percent, y_percent;
float lowx_float, highx_float, lowy_float, highy_float;
@@ -1212,9 +1212,9 @@ public class ScaleInternal {
int convy_int, convx_int;
int l, m;
int left, right;
-
+
if( (widthin == (widthout * 2)) && (heightin == (heightout * 2)) ) {
- HalveImage.halveImage_uint( components, widthin, heightin, datain, dataout,
+ HalveImage.halveImage_uint( components, widthin, heightin, datain, dataout,
element_size, ysize, group_size, myswap_bytes );
return;
}
@@ -1224,14 +1224,14 @@ public class ScaleInternal {
convy_float = convy - convy_int;
convx_int = (int)Math.floor( convx );
convx_float = convx - convx_int;
-
+
area = convx * convy;
-
+
lowy_int = 0;
lowy_float = 0.0f;
highy_int = convy_int;
highy_float = convy_float;
-
+
for( i = 0; i < heightout; i++ ) {
// Clamp here to be sure we don't read beyond input buffer.
if (highy_int >= heightin)
@@ -1247,18 +1247,18 @@ public class ScaleInternal {
highx_int = convx_int;
highx_float = convx_float;
}
-
+
for( j = 0; j < widthout; j++ ) {
-
+
// Ok, now apply box filter to box that goes from (lowx, lowy)
// to (highx, highy) on input data into this pixel on output
// data.
totals[0] = totals[1] = totals[2] = totals[3] = 0.0f;
-
+
// caulate the value for pixels in the 1st row
xindex = lowx_int * group_size;
if( ( highy_int > lowy_int ) && ( highx_int > lowx_int ) ) {
-
+
y_percent = 1 - lowy_float;
temp = xindex + lowy_int * ysize;
percent = y_percent * ( 1 - lowx_float );
@@ -1293,7 +1293,7 @@ public class ScaleInternal {
totals[k] += (0x00000000FFFFFFFF & datain.getInt()) * percent;
}
}
-
+
// calculate the value for pixels in the last row
y_percent = highy_float;
percent = y_percent * ( 1 - lowx_float );
@@ -1327,7 +1327,7 @@ public class ScaleInternal {
totals[k] += (0x00000000FFFFFFFF & datain.getInt()) * percent;
}
}
-
+
// calculate the value for the pixels in the 1st and last column
for( m = lowy_int + 1; m < highy_int; m++ ) {
left += ysize;
@@ -1427,7 +1427,7 @@ public class ScaleInternal {
}
}
}
-
+
// this is for the pixels in the body
temp0 = xindex + group_size + ( lowy_int + 1 ) * ysize;
for( m = lowy_int + 1; m < highy_int; m++ ) {
@@ -1445,7 +1445,7 @@ public class ScaleInternal {
}
temp0 += ysize;
}
-
+
outindex = ( j + ( i * widthout ) ) * components;
float value = 0.0f;
for( k = 0; k < components; k++ ) {
@@ -1483,10 +1483,10 @@ public class ScaleInternal {
}
}
}
-
+
public static void scale_internal_int( int components, int widthin, int heightin,
- ByteBuffer datain, int widthout, int heightout,
- IntBuffer dataout, int element_size, int ysize,
+ ByteBuffer datain, int widthout, int heightout,
+ IntBuffer dataout, int element_size, int ysize,
int group_size, boolean myswap_bytes ) {
float x, convx;
float y, convy;
@@ -1495,11 +1495,11 @@ public class ScaleInternal {
float[] totals = new float[4];
float area;
int i, j, k, xindex;
-
+
int temp, temp0;
int temp_index;
int outindex;
-
+
int lowx_int, highx_int, lowy_int, highy_int;
float x_percent, y_percent;
float lowx_float, highx_float, lowy_float, highy_float;
@@ -1507,11 +1507,11 @@ public class ScaleInternal {
int convy_int, convx_int;
int l, m;
int left, right;
-
+
long swapbuf; // unsigned buffer
-
+
if( (widthin == (widthout * 2)) && (heightin == (heightout * 2)) ) {
- HalveImage.halveImage_int( components, widthin, heightin, datain, dataout,
+ HalveImage.halveImage_int( components, widthin, heightin, datain, dataout,
element_size, ysize, group_size, myswap_bytes );
return;
}
@@ -1521,14 +1521,14 @@ public class ScaleInternal {
convy_float = convy - convy_int;
convx_int = (int)Math.floor( convx );
convx_float = convx - convx_int;
-
+
area = convx * convy;
-
+
lowy_int = 0;
lowy_float = 0.0f;
highy_int = convy_int;
highy_float = convy_float;
-
+
for( i = 0; i < heightout; i++ ) {
// Clamp here to be sure we don't read beyond input buffer.
if (highy_int >= heightin)
@@ -1544,18 +1544,18 @@ public class ScaleInternal {
highx_int = convx_int;
highx_float = convx_float;
}
-
+
for( j = 0; j < widthout; j++ ) {
-
+
// Ok, now apply box filter to box that goes from (lowx, lowy)
// to (highx, highy) on input data into this pixel on output
// data.
totals[0] = totals[1] = totals[2] = totals[3] = 0.0f;
-
+
// caulate the value for pixels in the 1st row
xindex = lowx_int * group_size;
if( ( highy_int > lowy_int ) && ( highx_int > lowx_int ) ) {
-
+
y_percent = 1 - lowy_float;
temp = xindex + lowy_int * ysize;
percent = y_percent * ( 1 - lowx_float );
@@ -1593,7 +1593,7 @@ public class ScaleInternal {
totals[k] += datain.getInt() * percent;
}
}
-
+
// calculate the value for pixels in the last row
y_percent = highy_float;
percent = y_percent * ( 1 - lowx_float );
@@ -1630,7 +1630,7 @@ public class ScaleInternal {
totals[k] += datain.getInt() * percent;
}
}
-
+
// calculate the value for the pixels in the 1st and last column
for( m = lowy_int + 1; m < highy_int; m++ ) {
left += ysize;
@@ -1736,7 +1736,7 @@ public class ScaleInternal {
}
}
}
-
+
// this is for the pixels in the body
temp0 = xindex + group_size + ( lowy_int + 1 ) * ysize;
for( m = lowy_int + 1; m < highy_int; m++ ) {
@@ -1755,7 +1755,7 @@ public class ScaleInternal {
}
temp0 += ysize;
}
-
+
outindex = ( j + ( i * widthout ) ) * components;
for( k = 0; k < components; k++ ) {
dataout.position( outindex + k );
@@ -1787,10 +1787,10 @@ public class ScaleInternal {
}
}
}
-
+
public static void scale_internal_float( int components, int widthin, int heightin,
- ByteBuffer datain, int widthout, int heightout,
- FloatBuffer dataout, int element_size, int ysize,
+ ByteBuffer datain, int widthout, int heightout,
+ FloatBuffer dataout, int element_size, int ysize,
int group_size, boolean myswap_bytes ) {
float x, convx;
float y, convy;
@@ -1799,11 +1799,11 @@ public class ScaleInternal {
float[] totals = new float[4];
float area;
int i, j, k, xindex;
-
+
int temp, temp0;
int temp_index;
int outindex;
-
+
int lowx_int, highx_int, lowy_int, highy_int;
float x_percent, y_percent;
float lowx_float, highx_float, lowy_float, highy_float;
@@ -1811,11 +1811,11 @@ public class ScaleInternal {
int convy_int, convx_int;
int l, m;
int left, right;
-
+
float swapbuf; // unsigned buffer
-
+
if( (widthin == (widthout * 2)) && (heightin == (heightout * 2)) ) {
- HalveImage.halveImage_float( components, widthin, heightin, datain, dataout,
+ HalveImage.halveImage_float( components, widthin, heightin, datain, dataout,
element_size, ysize, group_size, myswap_bytes );
return;
}
@@ -1825,14 +1825,14 @@ public class ScaleInternal {
convy_float = convy - convy_int;
convx_int = (int)Math.floor( convx );
convx_float = convx - convx_int;
-
+
area = convx * convy;
-
+
lowy_int = 0;
lowy_float = 0.0f;
highy_int = convy_int;
highy_float = convy_float;
-
+
for( i = 0; i < heightout; i++ ) {
// Clamp here to be sure we don't read beyond input buffer.
if (highy_int >= heightin)
@@ -1848,18 +1848,18 @@ public class ScaleInternal {
highx_int = convx_int;
highx_float = convx_float;
}
-
+
for( j = 0; j < widthout; j++ ) {
-
+
// Ok, now apply box filter to box that goes from (lowx, lowy)
// to (highx, highy) on input data into this pixel on output
// data.
totals[0] = totals[1] = totals[2] = totals[3] = 0.0f;
-
+
// caulate the value for pixels in the 1st row
xindex = lowx_int * group_size;
if( ( highy_int > lowy_int ) && ( highx_int > lowx_int ) ) {
-
+
y_percent = 1 - lowy_float;
temp = xindex + lowy_int * ysize;
percent = y_percent * ( 1 - lowx_float );
@@ -1897,7 +1897,7 @@ public class ScaleInternal {
totals[k] += datain.getFloat() * percent;
}
}
-
+
// calculate the value for pixels in the last row
y_percent = highy_float;
percent = y_percent * ( 1 - lowx_float );
@@ -1934,7 +1934,7 @@ public class ScaleInternal {
totals[k] += datain.getFloat() * percent;
}
}
-
+
// calculate the value for the pixels in the 1st and last column
for( m = lowy_int + 1; m < highy_int; m++ ) {
left += ysize;
@@ -2040,7 +2040,7 @@ public class ScaleInternal {
}
}
}
-
+
// this is for the pixels in the body
temp0 = xindex + group_size + ( lowy_int + 1 ) * ysize;
for( m = lowy_int + 1; m < highy_int; m++ ) {
@@ -2059,7 +2059,7 @@ public class ScaleInternal {
}
temp0 += ysize;
}
-
+
outindex = ( j + ( i * widthout ) ) * components;
for( k = 0; k < components; k++ ) {
dataout.position( outindex + k );
@@ -2091,28 +2091,28 @@ public class ScaleInternal {
}
}
}
-
- public static void scaleInternalPackedPixel( int components, Extract extract,
+
+ public static void scaleInternalPackedPixel( int components, Extract extract,
int widthIn, int heightIn, ByteBuffer dataIn, int widthOut,
int heightOut, ByteBuffer dataOut, int pixelSizeInBytes,
int rowSizeInBytes, boolean isSwap ) {
float x, convx;
float y, convy;
float percent;
-
+
// max components in a format is 4, so
float[] totals = new float[4];
float[] extractTotals = new float[4];
float[] extractMoreTotals = new float[4];
float[] shoveTotals = new float[4];
-
+
float area;
int i, j, k, xindex;
-
+
int temp, temp0;
int temp_index;
int outIndex = 0;
-
+
int lowx_int, highx_int, lowy_int, highy_int;
float x_percent, y_percent;
float lowx_float, highx_float, lowy_float, highy_float;
@@ -2120,7 +2120,7 @@ public class ScaleInternal {
int convy_int, convx_int;
int l, m;
int left, right;
-
+
if( widthIn == widthOut * 2 && heightIn == heightOut * 2 ) {
HalveImage.halveImagePackedPixel( components, extract, widthIn, heightIn, dataIn, dataOut,
pixelSizeInBytes, rowSizeInBytes, isSwap );
@@ -2132,14 +2132,14 @@ public class ScaleInternal {
convy_float = convy - convy_int;
convx_int = (int)Math.floor( convx );
convx_float = convx - convx_int;
-
+
area = convx * convy;
-
+
lowy_int = 0;
lowy_float = 0.0f;
highy_int = convy_int;
highy_float = convx_float;
-
+
for( i = 0; i < heightOut; i++ ) {
// Clamp here to be sure we don't read beyond input buffer.
if (highy_int >= heightIn)
@@ -2148,16 +2148,16 @@ public class ScaleInternal {
lowx_float = 0.0f;
highx_int = convx_int;
highx_float = convx_float;
-
+
for( j = 0; j < widthOut; j++ ) {
// ok now apply box filter to box that goes from( lowx, lowy )
// to ( highx, highy ) on input data into this pixel on output data
totals[0] = totals[1] = totals[2] = totals[3] = 0.0f;
-
+
// calculate that value for pixels in the 1st row
xindex = lowx_int * pixelSizeInBytes;
if( (highy_int > lowy_int) && (highx_int > lowx_int) ) {
-
+
y_percent = 1 - lowy_float;
temp = xindex + lowy_int * rowSizeInBytes;
percent = y_percent * ( 1 - lowx_float );
@@ -2184,7 +2184,7 @@ public class ScaleInternal {
totals[k] += extractTotals[k] * percent;
}
// calculate the value for pixels in the last row
-
+
y_percent = highy_float;
percent = y_percent * ( 1 - lowx_float );
temp = xindex + highy_int * rowSizeInBytes;
@@ -2207,7 +2207,7 @@ public class ScaleInternal {
for( k = 0; k < components; k++ ) {
totals[k] += extractTotals[k] * percent;
}
-
+
// calculate the value for pixels in the 1st and last column
for( m = lowy_int + 1; m < highy_int; m++ ) {
left += rowSizeInBytes;
@@ -2277,7 +2277,7 @@ public class ScaleInternal {
totals[k] += extractTotals[k] * percent;
}
}
-
+
// this is for the pixels in the body
temp0 = xindex + pixelSizeInBytes + ( lowy_int + 1 ) * rowSizeInBytes;
for( m = lowy_int + 1; m < highy_int; m++ ) {
@@ -2292,7 +2292,7 @@ public class ScaleInternal {
}
temp0 += rowSizeInBytes;
}
-
+
outIndex = ( j + ( i * widthOut ) );
for( k = 0; k < components; k++ ) {
shoveTotals[k] = totals[k] / area;
@@ -2325,7 +2325,7 @@ public class ScaleInternal {
}
assert( outIndex == ( widthOut * heightOut - 1) );
}
-
+
public static void scaleInternal3D( int components, int widthIn, int heightIn,
int depthIn, ShortBuffer dataIn, int widthOut, int heightOut,
int depthOut, ShortBuffer dataOut ) {
@@ -2339,9 +2339,9 @@ public class ScaleInternal {
float volume;
int i, j, d, k, zint, yint, xint, xindex, yindex, zindex;
int temp;
-
+
lowy = highy = lowx = highx = 0.0f;
-
+
convz = (float)depthIn / depthOut;
convy = (float)heightIn / heightOut;
convx = (float)widthIn / widthOut;
@@ -2375,13 +2375,13 @@ public class ScaleInternal {
highz = x + 0.5f;
lowz = x - 0.5f;
}
-
+
// Ok, now apply box filter to box that goes from ( lowx, lowy, lowz )
// to ( highx, highy, highz ) on input data into this pixel on output data
-
+
totals[0] = totals[1] = totals[2] = totals[3] = 0.0f;
volume = 0.0f;
-
+
z = lowz;
zint = (int)(Math.floor( z ) );
while( z < highz ) {
@@ -2391,7 +2391,7 @@ public class ScaleInternal {
} else {
zpercent = zint + 1 - z;
}
-
+
y = lowy;
yint = (int)(Math.floor( y ) );
while( y < highy ) {
@@ -2401,10 +2401,10 @@ public class ScaleInternal {
} else {
ypercent = yint + 1 - y;
}
-
+
x = lowx;
xint = (int)(Math.floor( x ) );
-
+
while( x < highx ) {
xindex = (xint + widthIn ) % widthIn;
if( highx < xint + 1 ) {
@@ -2412,10 +2412,10 @@ public class ScaleInternal {
} else {
xpercent = xint + 1 - x;
}
-
+
percent = xpercent * ypercent * zpercent;
volume += percent;
-
+
temp = (xindex + ( yindex *widthIn) + (zindex * widthIn *heightIn)) * components;
for( k = 0; k < components; k++ ) {
assert( 0 <= (temp+k) && (temp+k) < (widthIn * heightIn * depthIn * components) );
@@ -2430,7 +2430,7 @@ public class ScaleInternal {
zint++;
z = zint;
} // while z
-
+
temp = ( j + ( i * widthOut ) + (d * widthOut * heightOut ) ) * components;
for( k = 0; k < components; k++ ) {
// totals should be rounded in the case of enlarging an rgb ramp when the type is 332 or 4444
@@ -2441,48 +2441,48 @@ public class ScaleInternal {
}
}
}
-
- public static int gluScaleImage3D( GL gl, int format, int widthIn, int heightIn,
- int depthIn, int typeIn, ByteBuffer dataIn, int widthOut, int heightOut,
+
+ public static int gluScaleImage3D( GL gl, int format, int widthIn, int heightIn,
+ int depthIn, int typeIn, ByteBuffer dataIn, int widthOut, int heightOut,
int depthOut, int typeOut, ByteBuffer dataOut ) {
int components;
ShortBuffer beforeImage, afterImage;
PixelStorageModes psm = new PixelStorageModes();
-
+
if( widthIn == 0 || heightIn == 0 || depthIn == 0 ||
widthOut == 0 || heightOut == 0 || depthOut == 0 ) {
return( 0 );
}
-
+
if( widthIn < 0 || heightIn < 0 || depthIn < 0 ||
widthOut < 0 || heightOut < 0 || depthOut < 0 ) {
return( GLU.GLU_INVALID_VALUE );
}
-
- if( !Mipmap.legalFormat(format) || !Mipmap.legalType(typeIn) ||
+
+ if( !Mipmap.legalFormat(format) || !Mipmap.legalType(typeIn) ||
!Mipmap.legalType(typeOut) || typeIn == GL2.GL_BITMAP ||
typeOut == GL2.GL_BITMAP ) {
return( GLU.GLU_INVALID_ENUM );
}
-
+
if( !Mipmap.isLegalFormatForPackedPixelType( format, typeIn ) ) {
return( GLU.GLU_INVALID_OPERATION );
}
-
+
if( !Mipmap.isLegalFormatForPackedPixelType( format, typeOut ) ) {
return( GLU.GLU_INVALID_OPERATION );
}
-
+
try {
- beforeImage = Buffers.newDirectByteBuffer( Mipmap.imageSize3D( widthIn,
+ beforeImage = Buffers.newDirectByteBuffer( Mipmap.imageSize3D( widthIn,
heightIn, depthIn, format, GL2.GL_UNSIGNED_SHORT ) ).asShortBuffer();
- afterImage = Buffers.newDirectByteBuffer( Mipmap.imageSize3D( widthIn,
+ afterImage = Buffers.newDirectByteBuffer( Mipmap.imageSize3D( widthIn,
heightIn, depthIn, format, GL2.GL_UNSIGNED_SHORT ) ).asShortBuffer();
} catch( OutOfMemoryError err ) {
return( GLU.GLU_OUT_OF_MEMORY );
}
Mipmap.retrieveStoreModes3D( gl, psm );
-
+
Image.fillImage3D( psm, widthIn, heightIn, depthIn, format, typeIn,
Mipmap.is_index( format ), dataIn, beforeImage );
components = Mipmap.elements_per_group( format, 0 );
@@ -2490,7 +2490,7 @@ public class ScaleInternal {
beforeImage, widthOut, heightOut, depthOut, afterImage );
Image.emptyImage3D( psm, widthOut, heightOut, depthOut, format, typeOut,
Mipmap.is_index( format ), afterImage, dataOut );
-
+
return( 0 );
}
}