1991 jobject jpixels = NULL; |
1992 jobject jpixels = NULL; |
1992 jint *pixels; |
1993 jint *pixels; |
1993 unsigned char *dP = dataP; |
1994 unsigned char *dP = dataP; |
1994 #define NUM_LINES 10 |
1995 #define NUM_LINES 10 |
1995 int numLines = NUM_LINES; |
1996 int numLines = NUM_LINES; |
1996 int nbytes = rasterP->width*4*NUM_LINES; |
1997 /* it is safe to calculate the scan length, because width has been verified |
|
1998 * on creation of the mlib image |
|
1999 */ |
|
2000 int scanLength = rasterP->width * 4; |
|
2001 |
|
2002 int nbytes = 0; |
|
2003 if (!SAFE_TO_MULT(numLines, scanLength)) { |
|
2004 return -1; |
|
2005 } |
|
2006 |
|
2007 nbytes = numLines * scanLength; |
1997 |
2008 |
1998 for (y=0; y < rasterP->height; y+=numLines) { |
2009 for (y=0; y < rasterP->height; y+=numLines) { |
1999 /* getData, one scanline at a time */ |
2010 /* getData, one scanline at a time */ |
2000 if (y+numLines > rasterP->height) { |
2011 if (y+numLines > rasterP->height) { |
2001 numLines = rasterP->height - y; |
2012 numLines = rasterP->height - y; |
2002 nbytes = rasterP->width*4*numLines; |
2013 nbytes = numLines * scanLength; |
2003 } |
2014 } |
2004 jpixels = (*env)->CallObjectMethod(env, imageP->jimage, |
2015 jpixels = (*env)->CallObjectMethod(env, imageP->jimage, |
2005 g_BImgGetRGBMID, 0, y, |
2016 g_BImgGetRGBMID, 0, y, |
2006 rasterP->width, numLines, |
2017 rasterP->width, numLines, |
2007 jpixels,0, rasterP->width); |
2018 jpixels,0, rasterP->width); |
2127 } |
2138 } |
2128 #endif |
2139 #endif |
2129 if (cvtToDefault) { |
2140 if (cvtToDefault) { |
2130 int status = 0; |
2141 int status = 0; |
2131 *mlibImagePP = (*sMlibSysFns.createFP)(MLIB_BYTE, 4, width, height); |
2142 *mlibImagePP = (*sMlibSysFns.createFP)(MLIB_BYTE, 4, width, height); |
|
2143 if (*mlibImagePP == NULL) { |
|
2144 return -1; |
|
2145 } |
2132 cDataP = (unsigned char *) mlib_ImageGetData(*mlibImagePP); |
2146 cDataP = (unsigned char *) mlib_ImageGetData(*mlibImagePP); |
2133 /* Make sure the image is cleared */ |
2147 /* Make sure the image is cleared. |
|
2148 * NB: the image dimension is already verified, so we can |
|
2149 * safely calculate the length of the buffer. |
|
2150 */ |
2134 memset(cDataP, 0, width*height*4); |
2151 memset(cDataP, 0, width*height*4); |
2135 |
2152 |
2136 if (!isSrc) { |
2153 if (!isSrc) { |
2137 return 0; |
2154 return 0; |
2138 } |
2155 } |
2378 return 0; |
2395 return 0; |
2379 |
2396 |
2380 case sun_awt_image_IntegerComponentRaster_TYPE_BYTE_PACKED_SAMPLES: |
2397 case sun_awt_image_IntegerComponentRaster_TYPE_BYTE_PACKED_SAMPLES: |
2381 *mlibImagePP = (*sMlibSysFns.createFP)(MLIB_BYTE, rasterP->numBands, |
2398 *mlibImagePP = (*sMlibSysFns.createFP)(MLIB_BYTE, rasterP->numBands, |
2382 width, height); |
2399 width, height); |
|
2400 if (*mlibImagePP == NULL) { |
|
2401 return -1; |
|
2402 } |
2383 if (!isSrc) return 0; |
2403 if (!isSrc) return 0; |
2384 cDataP = (unsigned char *) mlib_ImageGetData(*mlibImagePP); |
2404 cDataP = (unsigned char *) mlib_ImageGetData(*mlibImagePP); |
2385 return expandPackedBCR(env, rasterP, -1, cDataP); |
2405 return expandPackedBCR(env, rasterP, -1, cDataP); |
2386 |
2406 |
2387 case sun_awt_image_IntegerComponentRaster_TYPE_USHORT_PACKED_SAMPLES: |
2407 case sun_awt_image_IntegerComponentRaster_TYPE_USHORT_PACKED_SAMPLES: |
2388 if (rasterP->sppsm.maxBitSize <= 8) { |
2408 if (rasterP->sppsm.maxBitSize <= 8) { |
2389 *mlibImagePP = (*sMlibSysFns.createFP)(MLIB_BYTE, rasterP->numBands, |
2409 *mlibImagePP = (*sMlibSysFns.createFP)(MLIB_BYTE, rasterP->numBands, |
2390 width, height); |
2410 width, height); |
|
2411 if (*mlibImagePP == NULL) { |
|
2412 return -1; |
|
2413 } |
2391 if (!isSrc) return 0; |
2414 if (!isSrc) return 0; |
2392 cDataP = (unsigned char *) mlib_ImageGetData(*mlibImagePP); |
2415 cDataP = (unsigned char *) mlib_ImageGetData(*mlibImagePP); |
2393 return expandPackedSCR(env, rasterP, -1, cDataP); |
2416 return expandPackedSCR(env, rasterP, -1, cDataP); |
2394 } |
2417 } |
2395 break; |
2418 break; |
2396 case sun_awt_image_IntegerComponentRaster_TYPE_INT_PACKED_SAMPLES: |
2419 case sun_awt_image_IntegerComponentRaster_TYPE_INT_PACKED_SAMPLES: |
2397 if (rasterP->sppsm.maxBitSize <= 8) { |
2420 if (rasterP->sppsm.maxBitSize <= 8) { |
2398 *mlibImagePP = (*sMlibSysFns.createFP)(MLIB_BYTE, rasterP->numBands, |
2421 *mlibImagePP = (*sMlibSysFns.createFP)(MLIB_BYTE, rasterP->numBands, |
2399 width, height); |
2422 width, height); |
|
2423 if (*mlibImagePP == NULL) { |
|
2424 return -1; |
|
2425 } |
2400 if (!isSrc) return 0; |
2426 if (!isSrc) return 0; |
2401 cDataP = (unsigned char *) mlib_ImageGetData(*mlibImagePP); |
2427 cDataP = (unsigned char *) mlib_ImageGetData(*mlibImagePP); |
2402 return expandPackedICR(env, rasterP, -1, cDataP); |
2428 return expandPackedICR(env, rasterP, -1, cDataP); |
2403 } |
2429 } |
2404 break; |
2430 break; |