/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#include <stdio.h>
#include <stdlib.h>
#include "awt_parseImage.h"
#include "imageInitIDs.h"
#include "java_awt_Transparency.h"
#include "java_awt_image_BufferedImage.h"
#include "sun_awt_image_IntegerComponentRaster.h"
#include "sun_awt_image_ImagingLib.h"
#include "java_awt_color_ColorSpace.h"
#include "awt_Mlib.h"
#include "safe_alloc.h"
#include "safe_math.h"
/* Parse the buffered image. All of the raster information is returned in the
* imagePP structure.
*
* The handleCustom parameter specifies whether or not the caller
* can use custom channels. If it is false and a custom channel
* is encountered, the returned value will be 0 and all structures
* will be deallocated.
*
* Return value:
* -1: Exception
* 0: Can't do it.
* 1: Success
*/
int handleCustom) {
int status;
/* Make sure the image exists */
return -1;
}
return -1;
}
/* Retrieve the raster */
g_BImgRasterID)) == NULL) {
return 0;
}
/* Retrieve the image type */
/* Parse the raster */
return status;
}
/* Retrieve the color model */
return 0;
}
/* Parse the color model */
return 0;
}
/* Set hints */
return 0;
}
return status;
}
/* Verifies whether the channel offsets are sane and correspond to the type of
* the raster.
*
* Return value:
* 0: Failure: channel offsets are invalid
* 1: Success
*/
switch (rasterP->rasterType) {
case COMPONENT_RASTER_TYPE:
return 0;
}
return 0;
}
return 0;
}
for (i = 0; i < rasterP->numDataElements; i++) {
return 0;
}
// an overflow, or insufficient buffer capacity
return 0;
}
}
return 1;
case BANDED_RASTER_TYPE:
// NB:caller does not support the banded rasters yet,
// so this branch of the code must be re-defined in
// order to provide valid criteria for the data offsets
// At the moment, we prohibit banded rasters as well.
return 0;
default:
// PACKED_RASTER_TYPE: does not support channel offsets
// UNKNOWN_RASTER_TYPE: should not be used, likely indicates an error
return 0;
}
}
/* Parse the raster. All of the raster information is returned in the
* rasterP structure.
*
* Return value:
* -1: Exception
* 0: Can't do it (Custom channel)
* 1: Success
*/
/* int status;*/
return -1;
}
return -1;
}
// make sure that the raster type is initialized
{
/*
* we can't handle such kind of rasters due to limitations
*/
return 0;
}
{
return -1;
}
}
}
}
}
}
/* Out of memory */
return -1;
}
}
else {
/* Custom raster */
return 0;
}
// do basic validation of the raster structure
{
// invalid raster
return -1;
}
// channel (data) offsets
switch (rasterP->rasterType) {
case COMPONENT_RASTER_TYPE:
case BANDED_RASTER_TYPE: // note that this routine does not support banded rasters at the moment
// get channel (data) offsets
}
/* Out of memory */
return -1;
}
// unable to verify the raster
return -1;
}
// verify whether channel offsets look sane
return -1;
}
break;
default:
; // PACKED_RASTER_TYPE does not use the channel offsets.
}
/* additional check for sppsm fields validity: make sure that
* size of raster samples doesn't exceed the data type capacity.
*/
{
return -1;
}
#if 0
#endif
return 1;
}
{
{
}
else {
}
}
{
}
return type;
}
ColorModelS_t *cmP) {
/*jmethodID jID; */
int i;
return -1;
}
return -1;
}
// invalid number of components?
return -1;
}
}
return -1;
}
for (i=0; i < cmP->numComponents; i++) {
}
}
/* look for standard cases */
} else if (imageType == java_awt_image_BufferedImage_TYPE_INT_ARGB_PRE ||
{
}
else {
/* Figure out if this is the default CM */
"Unable to find default CM");
return -1;
}
}
}
/* check whether image attributes correspond to default cm */
if (cmP->isDefaultCompatCM) {
{
return -1;
}
for (i = 0; i < cmP->numComponents; i++) {
return -1;
}
}
}
/* Get index color model attributes */
{
/* Need to find the transparent index */
NULL);
return -1;
}
if ((rgb[i]&0xff000000) == 0) {
break;
}
}
/* Now what? No transparent pixel... */
}
}
}
return 1;
}
if (rasterP->chanOffsets) {
}
if (freeRasterP) {
}
}
}
}
/* Free the raster */
if (freeImageP) {
}
}
static int
// check whether raster and color model are compatible
return -1;
}
}
}
return -1;
}
}
{
/* These hints are #bytes */
} else if (imageType ==java_awt_image_BufferedImage_TYPE_4BYTE_ABGR ||
{
}
else {
}
} else if (imageType==java_awt_image_BufferedImage_TYPE_USHORT_565_RGB ||
int i;
case BYTE_DATA_TYPE:
}
else {
}
break;
case SHORT_DATA_TYPE:
break;
case INT_DATA_TYPE:
default:
break;
}
hintP->colorOrder[i] = i;
}
}
/* Figure out if it is interleaved */
int i;
int diff;
int banded = 0;
}
}
/* Overlapping samples */
/* Could just copy */
return -1;
}
}
banded = 1;
}
/* Ignore the case if bands are overlapping */
}
case BYTE_DATA_TYPE:
break;
case SHORT_DATA_TYPE:
break;
default:
/* Don't handle any other case */
return -1;
}
}
}
else if (banded == 1) {
/* REMIND: Not necessarily correct */
}
}
else {
return -1;
}
}
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
*/
{
/* given raster is not compatible with the color model,
* so the operation has to be aborted.
*/
return -1;
}
}
break;
}
else {
}
}
}
if (hintP->needToExpand) {
case BYTE_DATA_TYPE:
break;
case SHORT_DATA_TYPE:
break;
case INT_DATA_TYPE:
break;
default:
/* Don't know what it is */
return -1;
}
}
else {
}
}
else {
/* REMIND: Need to handle more cases */
return -1;
}
return 1;
}
/*
* This routine will fill in a buffer of data for either 1 band or all
* bands (if band == -1).
*/
unsigned char *bufferP) {
int y;
int i;
int off;
int *dataP;
int maxBytes = w;
return -1;
}
/* Here is the generic code */
if (band >= 0) {
int dOff;
return -1;
}
off = 0;
for (y=0; y < h; ) {
0, y, w,
NULL);
return -1;
}
}
if (y+maxLines < h) {
y += maxLines;
}
else {
y++;
maxBytes = w;
}
}
}
else {
off = 0;
for (y=0; y < h; ) {
0, y, w,
NULL);
return -1;
}
for (i=0; i < maxBytes; i++) {
}
if (y+maxLines < h) {
y += maxLines;
}
else {
y++;
}
}
}
return 0;
}
unsigned char *bufferP) {
int y;
int i;
int off;
int *dataP;
int maxBytes = w;
/* Here is the generic code */
return -1;
}
if (band >= 0) {
int dOff;
return -1;
}
off = 0;
for (y=0; y < h; y+=maxLines) {
if (y+maxLines > h) {
maxLines = h - y;
}
NULL);
return -1;
}
}
0, y, w,
}
}
else {
off = 0;
for (y=0; y < h; y+=maxLines) {
if (y+maxLines > h) {
maxLines = h - y;
}
NULL);
return -1;
}
for (i=0; i < maxBytes; i++) {
}
0, y, w,
}
}
return 0;
}
unsigned short *bufferP) {
int y;
int i;
int off;
int *dataP;
return -1;
}
/* Here is the generic code */
if (band >= 0) {
int dOff;
return -1;
}
off = 0;
for (y=0; y < h; y += maxLines) {
if (y+maxLines > h) {
maxLines = h - y;
}
0, y, w,
NULL);
return -1;
}
}
}
}
else {
off = 0;
for (y=0; y < h; y+=maxLines) {
if (y+maxLines > h) {
maxLines = h - y;
}
0, y, w,
NULL);
return -1;
}
for (i=0; i < maxBytes; i++) {
}
}
}
return 0;
}
unsigned short *bufferP) {
int y;
int i;
int off;
int *dataP;
int maxBytes = w;
return -1;
}
/* Here is the generic code */
return -1;
}
if (band >= 0) {
int dOff;
off = 0;
for (y=0; y < h; y+=maxLines) {
if (y+maxLines > h) {
maxLines = h - y;
}
NULL);
return -1;
}
}
0, y, w,
}
}
else {
off = 0;
for (y=0; y < h; y+=maxLines) {
if (y+maxLines > h) {
maxLines = h - y;
}
NULL);
return -1;
}
for (i=0; i < maxBytes; i++) {
}
0, y, w,
}
}
return 0;
}