# HG changeset patch # User bae # Date 1353397602 -14400 # Node ID a4397a7163e34dd0923f882cc7fff1f9ba000d4d # Parent 6aa0f442dccb78c0822a876bed6fc7946973c1ea 8002325: Improve management of images Reviewed-by: prr, ahgross diff -r 6aa0f442dccb -r a4397a7163e3 jdk/src/share/native/sun/awt/image/awt_parseImage.c --- a/jdk/src/share/native/sun/awt/image/awt_parseImage.c Mon Nov 19 15:38:56 2012 -0800 +++ b/jdk/src/share/native/sun/awt/image/awt_parseImage.c Tue Nov 20 11:46:42 2012 +0400 @@ -223,9 +223,14 @@ return 0; } + rasterP->sppsm.isUsed = 0; + if ((*env)->IsInstanceOf(env, rasterP->jsampleModel, (*env)->FindClass(env,"java/awt/image/SinglePixelPackedSampleModel"))) { jobject jmask, joffs, jnbits; + + rasterP->sppsm.isUsed = 1; + rasterP->sppsm.maxBitSize = (*env)->GetIntField(env, rasterP->jsampleModel, g_SPPSMmaxBitID); @@ -711,6 +716,21 @@ } else if (cmodelP->cmType == DIRECT_CM_TYPE || cmodelP->cmType == PACKED_CM_TYPE) { int i; + + /* do some sanity check first: make sure that + * - sample model is SinglePixelPackedSampleModel + * - number of bands in the raster corresponds to the number + * of color components in the color model + */ + if (!rasterP->sppsm.isUsed || + rasterP->numBands != cmodelP->numComponents) + { + /* given raster is not compatible with the color model, + * so the operation has to be aborted. + */ + return -1; + } + if (cmodelP->maxNbits > 8) { hintP->needToExpand = TRUE; hintP->expandToNbits = cmodelP->maxNbits; diff -r 6aa0f442dccb -r a4397a7163e3 jdk/src/share/native/sun/awt/image/awt_parseImage.h --- a/jdk/src/share/native/sun/awt/image/awt_parseImage.h Mon Nov 19 15:38:56 2012 -0800 +++ b/jdk/src/share/native/sun/awt/image/awt_parseImage.h Tue Nov 20 11:46:42 2012 +0400 @@ -95,6 +95,7 @@ jint offsets[MAX_NUMBANDS]; jint nBits[MAX_NUMBANDS]; jint maxBitSize; + jint isUsed; // flag to indicate whether the raster sample model is SPPSM } SPPSampleModelS_t; /* Struct that holds information for the Raster object */