awt_ImagingLib.c revision 6352
157N/A * or visit www.oracle.com if you need additional information or have any
0N/A#include "sun_awt_image_ImagingLib.h"
0N/A#include "java_awt_Transparency.h"
0N/A#include "java_awt_image_AffineTransformOp.h"
0N/A#include "java_awt_image_BufferedImage.h"
0N/A#include "java_awt_color_ColorSpace.h"
0N/A#include "java_awt_image_ConvolveOp.h"
0N/A#include "sun_awt_image_IntegerComponentRaster.h"
0N/A#include "awt_ImagingLib.h"
0N/A#include "awt_parseImage.h"
0N/A#include "imageInitIDs.h"
0N/A#include <jni_util.h>
0N/A#include "awt_Mlib.h"
0N/A#include "safe_alloc.h"
0N/A#include "safe_math.h"
0N/A int needToCopy;
int addAlpha;
} mlibHintS_t;
* Static Variables/Structures *
static int s_timeIt = 0;
static int s_printIt = 0;
static int s_startOff = 0;
static int s_nomlib = 0;
void *dstdataP);
void *dstdataP);
unsigned char *outDataP);
unsigned char *outDataP);
unsigned char *outDataP);
int forceAlpha);
int forceAlpha);
int forceAlpha);
unsigned char *outDataP);
unsigned char *outDataP);
unsigned char *outDataP);
int supportsAlpha);
int supportsAlpha);
int supportsAlpha);
#ifdef DEBUG
switch(status) {
case MLIB_FAILURE:
case MLIB_NULLPOINTER:
case MLIB_OUTOFRANGE:
# define printMedialibError(x)
switch (edgeHint) {
return MLIB_EDGE_DST_COPY_SRC;
return MLIB_EDGE_DST_FILL_ZERO;
int i, scale;
int klen;
float kmax;
float *kern;
int kwidth;
int kheight;
int nbands;
if (s_nomlib) return 0;
w = kwidth;
h = kheight;
for (y=0; y < kheight; y++) {
for (x=0; x < kwidth; x++, i--) {
if (s_printIt) {
retStatus = 0;
if (s_printIt) {
unsigned int *dP;
if (s_startOff != 0) {
retStatus = 0;
return retStatus;
int i, scale;
int klen;
float kmax;
void *sdata;
void *ddata;
int kwidth;
int kheight;
float *kern;
if (s_nomlib) return 0;
w = kwidth;
h = kheight;
for (y=0; y < kheight; y++) {
for (x=0; x < kwidth; x++, i--) {
if (s_printIt) {
retStatus = 0;
if (s_printIt) {
unsigned int *dP;
if (s_startOff != 0) {
unsigned char *bdataP;
unsigned short *sdataP;
case BYTE_DATA_TYPE:
case SHORT_DATA_TYPE:
retStatus = 0;
return retStatus;
double *matrix;
void *sdata;
void *ddata;
unsigned int *dP;
int useIndexed;
int nbands;
if (s_nomlib) return 0;
if (s_timeIt) {
switch(interpType) {
if (s_printIt) {
if (s_printIt) {
retStatus = 0;
return retStatus;
double *matrix;
void *sdata;
void *ddata;
unsigned int *dP;
if (s_nomlib) return 0;
if (s_timeIt) {
switch(interpType) {
if (s_printIt) {
if (s_printIt) {
unsigned char *bdataP;
unsigned short *sdataP;
case MLIB_BYTE:
case MLIB_SHORT:
retStatus = 0;
return retStatus;
unsigned char *table;
#ifdef _LITTLE_ENDIAN
#ifdef SIMPLE_LOOKUP_LOOP
unsigned short s = *srcPixel++;
unsigned short s = *srcPixel++;
npix--;
for(x=nloop; x!=0; x--) {
for (i = 0; i < NLUT; i++) {
dstP[0] = (int)
for(x=nx; x!=0; x--) {
unsigned short s = *srcPixel++;
unsigned char **tbl;
int lut_nbands;
int nbands;
int ncomponents;
if (s_nomlib) return 0;
for (i = 0; i < nbands; i++) {
tbl = (unsigned char **)
for (i=0; i < lut_nbands; i++) {
lut[j] = j;
for (j=0; j < ncomponents; j++) {
for (i=0; i < lut_nbands; i++) {
retStatus = 0;
retStatus = 0;
retStatus = 0;
for (i=0; i < lut_nbands; i++) {
return retStatus;
void* sdata;
void* ddata;
int jlen;
int lut_nbands;
int src_nbands;
int dst_nbands;
if (s_nomlib) return 0;
ilut[i] = i;
for (i=0; i < lut_nbands; i++) {
for (i=0; i < lut_nbands; i++) {
retStatus = 0;
retStatus = 0;
unsigned char* bdataP;
unsigned short* sdataP;
case BYTE_DATA_TYPE:
case SHORT_DATA_TYPE:
retStatus = 0;
for (i=0; i < lut_nbands; i++) {
return retStatus;
char *start;
return JNI_FALSE;
/* This function is platform-dependent and is in awt_mlib.c */
return JNI_FALSE;
return JNI_TRUE;
int width;
int height;
#ifdef WORKING
int xOff;
int yOff;
int baseWidth;
int baseHeight;
int baseXoff;
int baseYoff;
width++;
height++;
int nbands = 0;
int ncomponents;
if (expandICM) {
return nbands;
case BYTE_DATA_TYPE:
case SHORT_DATA_TYPE:
case INT_DATA_TYPE:
unsigned char *dataP) {
int nbytes = 0;
g_BImgGetRGBMID, 0, y,
unsigned char *dataP) {
void *dataP;
unsigned char *cDataP;
int width;
int height;
if (0 && useEdges) {
width++;
height++;
width++;
height++;
if (cvtToDefault) {
int status = 0;
if (!isSrc) {
case INDEX_CM_TYPE:
case DIRECT_CM_TYPE:
case BYTE_DATA_TYPE:
case SHORT_DATA_TYPE:
case INT_DATA_TYPE:
} /* switch(imageP->cmodel.cmType) */
NULL);
unsigned int *dstP = (unsigned int *)
unsigned int *srcP = (unsigned int *)
for (x=0; x < width; x++) {
(unsigned char *)dataP
(unsigned short *)dataP
void *dataP;
unsigned char *cDataP;
unsigned short *sdataP;
int width;
int height;
int dataSize;
int offset;
if (0 && useEdges) {
width++;
height++;
width++;
height++;
NULL);
NULL);
NULL);
if (!isSrc) return 0;
if (!isSrc) return 0;
if (!isSrc) return 0;
case BYTE_DATA_TYPE:
if (isSrc) {
case SHORT_DATA_TYPE:
if (isSrc) {
void *dstdataP) {
void *dstdataP)
if (srcmlibImP) {
if (srcdataP) {
if (dstmlibImP) {
if (dstdataP) {
dstdataP, 0);
int mStride;
unsigned char *cDataP;
int *argb;
unsigned char *sP;
aIdx = 0;
aIdx = 0;
bIdx = 0;
rIdx = 0;
int *rgb;
int status = 0;
unsigned int *mP;
if (rgb) {
if (dataP) {
for (y=0; y < height; y++) {
for (y=0; y < height; y++) {
return status;
unsigned char *outDataP)
if (component < 0) {
if (roff[c] < 0) {
roff[c] = 0;
else loff[c] = 0;
*outP++ = (unsigned char)
<<loff[c]);
inP++;
*outP++ = (unsigned char)
<<loff[c]);
inP++;
c = component;
if (roff[0] < 0) {
roff[0] = 0;
else loff[c] = 0;
*outP++ = (unsigned char)
inP++;
int forceAlpha)
int a = numBands;
if (component < 0) {
if (roff[c] < 0) {
roff[c] = 0;
else loff[c] = 0;
if (forceAlpha) {
for (c=0; c < numBands; c++) {
*outP++ = (unsigned char)
<<loff[c]);
inP++;
*outP++ = (unsigned char)
<<loff[a]);
for (c=0; c < numBands; c++) {
*outP++ = (unsigned char)
<<loff[c]);
inP++;
c = component;
if (roff[0] < 0) {
roff[0] = 0;
else loff[c] = 0;
*outP++ = (unsigned char)
inP++;
unsigned char *outDataP)
if (component < 0) {
if (roff[c] < 0) {
roff[c] = 0;
else loff[c] = 0;
*outP++ = (unsigned char)
<<loff[c]);
inP++;
*outP++ = (unsigned char)
<<loff[c]);
inP++;
c = component;
if (roff[0] < 0) {
roff[0] = 0;
else loff[c] = 0;
*outP++ = (unsigned char)
inP++;
int forceAlpha)
int a = numBands;
if (component < 0) {
if (roff[c] < 0) {
roff[c] = 0;
else loff[c] = 0;
if (forceAlpha) {
for (c=0; c < numBands; c++) {
*outP++ = (unsigned char)
<<loff[c]);
inP++;
*outP++ = (unsigned char)
<<loff[a]);
for (c=0; c < numBands; c++) {
*outP++ = (unsigned char)
<<loff[c]);
inP++;
c = component;
if (roff[0] < 0) {
roff[0] = 0;
else loff[c] = 0;
*outP++ = (unsigned char)
inP++;
unsigned char *outDataP)
if (component < 0) {
if (roff[c] < 0) {
roff[c] = 0;
else loff[c] = 0;
<<loff[c]);
inP++;
<<loff[c]);
inP++;
c = component;
if (roff[0] < 0) {
roff[0] = 0;
else loff[c] = 0;
inP++;
int forceAlpha)
int a = numBands;
if (component < 0) {
if (roff[c] < 0) {
roff[c] = 0;
else loff[c] = 0;
if (forceAlpha) {
for (c=0; c < numBands; c++) {
<<loff[c]);
inP++;
<<loff[a]);
for (c=0; c < numBands; c++) {
<<loff[c]);
inP++;
c = component;
if (roff[0] < 0) {
roff[0] = 0;
else loff[c] = 0;
inP++;
unsigned char *inDataP)
if (component < 0) {
if (loff[c] < 0) {
loff[c] = 0;
else roff[c] = 0;
*outP = 0;
outP++;
c = component;
if (loff[0] < 0) {
loff[0] = 0;
else roff[c] = 0;
outP++;
unsigned char *inDataP)
if (component < 0) {
if (loff[c] < 0) {
loff[c] = 0;
else roff[c] = 0;
outP++;
c = component;
if (loff[0] < 0) {
loff[0] = 0;
else roff[c] = 0;
outP++;
unsigned char *inDataP)
if (component < 0) {
if (loff[c] < 0) {
loff[c] = 0;
else roff[c] = 0;
outP++;
c = component;
if (loff[0] < 0) {
loff[0] = 0;
else roff[c] = 0;
outP++;
int supportsAlpha)
if (component < 0) {
if (loff[c] < 0) {
loff[c] = 0;
else roff[c] = 0;
if (supportsAlpha) {
*outP = 0;
inP++;
outP++;
*outP = 0;
inP++;
outP++;
c = component;
if (loff[0] < 0) {
loff[0] = 0;
else roff[c] = 0;
outP++;
int supportsAlpha)
if (component < 0) {
if (loff[c] < 0) {
loff[c] = 0;
else roff[c] = 0;
if (supportsAlpha) {
inP++;
outP++;
inP++;
outP++;
c = component;
if (loff[0] < 0) {
loff[0] = 0;
else roff[c] = 0;
outP++;
int supportsAlpha)
if (component < 0) {
if (loff[c] < 0) {
loff[c] = 0;
else roff[c] = 0;
if (supportsAlpha) {
inP++;
outP++;
inP++;
outP++;
c = component;
if (loff[0] < 0) {
loff[0] = 0;
else roff[c] = 0;
outP++;
#define ABS(x) ((x) < 0 ? -(x) : (x))
int besti = 0;
int mindist, i, t, d;
if (d < mindist) {
besti = i;
mindist = d;
return besti;
t = red - r;
if (d >= mindist) {
t = green - g;
if (d >= mindist) {
t = blue - b;
if (d >= mindist) {
if (d < mindist) {
besti = i;
mindist = d;
return besti;