Package com.sun.media.jai.codecimpl.util

Examples of com.sun.media.jai.codecimpl.util.ImagingException


                throw new RuntimeException(msg);
            }
        } catch (Exception e) {
            String message = JaiI18N.getString("PNGImageDecoder1");
            ImagingListenerProxy.errorOccurred(message,
                                   new ImagingException(message, e),
                                   this, false);
/*
            e.printStackTrace();
            String msg = JaiI18N.getString("PNGImageDecoder1");
            throw new RuntimeException(msg);
*/
        }

        do {
            try {
                PNGChunk chunk;

                String chunkType = getChunkType(distream);
                if (chunkType.equals("IHDR")) {
                    chunk = readChunk(distream);
                    parse_IHDR_chunk(chunk);
                } else if (chunkType.equals("PLTE")) {
                    chunk = readChunk(distream);
                    parse_PLTE_chunk(chunk);
                } else if (chunkType.equals("IDAT")) {
                    chunk = readChunk(distream);
                    streamVec.add(new ByteArrayInputStream(chunk.getData()));
                } else if (chunkType.equals("IEND")) {
                    chunk = readChunk(distream);
                    parse_IEND_chunk(chunk);
                    break; // fall through to the bottom
                } else if (chunkType.equals("bKGD")) {
                    chunk = readChunk(distream);
                    parse_bKGD_chunk(chunk);
                } else if (chunkType.equals("cHRM")) {
                    chunk = readChunk(distream);
                    parse_cHRM_chunk(chunk);
                } else if (chunkType.equals("gAMA")) {
                    chunk = readChunk(distream);
                    parse_gAMA_chunk(chunk);
                } else if (chunkType.equals("hIST")) {
                    chunk = readChunk(distream);
                    parse_hIST_chunk(chunk);
                } else if (chunkType.equals("iCCP")) {
                    chunk = readChunk(distream);
                    parse_iCCP_chunk(chunk);
                } else if (chunkType.equals("pHYs")) {
                    chunk = readChunk(distream);
                    parse_pHYs_chunk(chunk);
                } else if (chunkType.equals("sBIT")) {
                    chunk = readChunk(distream);
                    parse_sBIT_chunk(chunk);
                } else if (chunkType.equals("sRGB")) {
                    chunk = readChunk(distream);
                    parse_sRGB_chunk(chunk);
                } else if (chunkType.equals("tEXt")) {
                    chunk = readChunk(distream);
                    parse_tEXt_chunk(chunk);
                } else if (chunkType.equals("tIME")) {
                    chunk = readChunk(distream);
                    parse_tIME_chunk(chunk);
                } else if (chunkType.equals("tRNS")) {
                    chunk = readChunk(distream);
                    parse_tRNS_chunk(chunk);
                } else if (chunkType.equals("zTXt")) {
                    chunk = readChunk(distream);
                    parse_zTXt_chunk(chunk);
                } else {
                    chunk = readChunk(distream);
                    // Output the chunk data in raw form

                    String type = chunk.getTypeString();
                    byte[] data = chunk.getData();
                    if (encodeParam != null) {
                        encodeParam.addPrivateChunk(type, data);
                    }
                    if (emitProperties) {
                        String key = "chunk_" + chunkIndex++ + ":" + type;
                        properties.put(key.toLowerCase(), data);
                    }
                }
            } catch (Exception e) {
                String message = JaiI18N.getString("PNGImageDecoder2");
                ImagingListenerProxy.errorOccurred(message,
                                       new ImagingException(message, e),
                                       this, false);
/*                e.printStackTrace();
                String msg = JaiI18N.getString("PNGImageDecoder2");
                throw new RuntimeException(msg);
*/
 
View Full Code Here


    public void dispose() {
        theTile = null;
    }

    private void sendExceptionToListener(String message, Exception e) {
        ImagingListenerProxy.errorOccurred(message, new ImagingException(message, e),
                               this, false);
    }
View Full Code Here

        try {
          // Write the image data.
            encoder.encode(bi);
        } catch(IOException e) {
            String message = JaiI18N.getString("JPEGImageEncoder2");
            ImagingListenerProxy.errorOccurred(message, new ImagingException(message, e),
                                   this, false);
//            throw new RuntimeException(e.getMessage());
        }

    }
View Full Code Here

    }
      }
  } catch (IOException ioe) {
            String message = JaiI18N.getString("BMPImageDecoder5");
            ImagingListenerProxy.errorOccurred(message,
                                   new ImagingException(message, ioe),
                                   this, false);
//      throw new RuntimeException(JaiI18N.getString("BMPImageDecoder5"));
  }

  if (height > 0) {
      // bottom up image
      isBottomUp = true;
  } else {
      // top down image
      isBottomUp = false;
      height = Math.abs(height);
  }

  // Reset Image Layout so there's only one tile.
  tileWidth = width;
  tileHeight = height;

  // When number of bitsPerPixel is <= 8, we use IndexColorModel.
   if (bitsPerPixel == 1 || bitsPerPixel == 4 || bitsPerPixel == 8) {

      numBands = 1;

      if (bitsPerPixel == 8) {
    sampleModel =
        RasterFactory.createPixelInterleavedSampleModel(
                 DataBuffer.TYPE_BYTE,
                 width, height,
                 numBands);
      } else {
    // 1 and 4 bit pixels can be stored in a packed format.
    sampleModel =
        new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE,
                width, height,
                bitsPerPixel);
      }

      // Create IndexColorModel from the palette.
      byte r[], g[], b[];
      int size;
      if (imageType == VERSION_2_1_BIT ||
    imageType == VERSION_2_4_BIT ||
    imageType == VERSION_2_8_BIT) {

    size = palette.length/3;

    if (size > 256) {
        size = 256;
    }

    int off;
    r = new byte[size];
    g = new byte[size];
    b = new byte[size];
    for (int i=0; i<size; i++) {
        off = 3 * i;
        b[i] = palette[off];
        g[i] = palette[off+1];
        r[i] = palette[off+2];
    }
      } else {
    size = palette.length/4;

    if (size > 256) {
        size = 256;
    }

    int off;
    r = new byte[size];
    g = new byte[size];
    b = new byte[size];
    for (int i=0; i<size; i++) {
        off = 4 * i;
        b[i] = palette[off];
        g[i] = palette[off+1];
        r[i] = palette[off+2];
    }
      }

      if (ImageCodec.isIndicesForGrayscale(r, g, b))
    colorModel = ImageCodec.createComponentColorModel(sampleModel);
      else
    colorModel = new IndexColorModel(bitsPerPixel, size, r, g, b);
  } else if (bitsPerPixel == 16) {
      numBands = 3;
            sampleModel =
    new SinglePixelPackedSampleModel(DataBuffer.TYPE_USHORT,
            width, height,
            new int[] {redMask, greenMask, blueMask});

      colorModel =
    new DirectColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
             16, redMask, greenMask, blueMask, 0,
             false, DataBuffer.TYPE_USHORT);
  } else if (bitsPerPixel == 32) {
      numBands = alphaMask == 0 ? 3 : 4;

            // The number of bands in the SampleModel is determined by
            // the length of the mask array passed in.
            int[] bitMasks = numBands == 3 ?
                new int[] {redMask, greenMask, blueMask} :
                new int[] {redMask, greenMask, blueMask, alphaMask};

      sampleModel =
          new SinglePixelPackedSampleModel(DataBuffer.TYPE_INT,
             width, height,
             bitMasks);

      colorModel =
    new DirectColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
             32, redMask, greenMask, blueMask, alphaMask,
             false, DataBuffer.TYPE_INT);
  } else {
      numBands = 3;
      // Create SampleModel
      sampleModel =
    RasterFactory.createPixelInterleavedSampleModel(
                    DataBuffer.TYPE_BYTE, width, height, numBands);

      colorModel =
    ImageCodec.createComponentColorModel(sampleModel);
      }

  try {
      inputStream.reset();
      inputStream.skip(bitmapOffset);
  } catch (IOException ioe) {
            String message = JaiI18N.getString("BMPImageDecoder9");
            ImagingListenerProxy.errorOccurred(message,
                                   new ImagingException(message, ioe),
                                   this, false);
  }
    }
View Full Code Here

                imSize - bytesRead);
      }
  } catch (IOException ioe) {
            String message = JaiI18N.getString("BMPImageDecoder6");
            ImagingListenerProxy.errorOccurred(message,
                                   new ImagingException(message, ioe),
                                   this, false);
//      throw new
//    RuntimeException(JaiI18N.getString("BMPImageDecoder6"));
  }
View Full Code Here

                imSize - bytesRead);
      }
  } catch (IOException ioe) {
            String message = JaiI18N.getString("BMPImageDecoder6");
            ImagingListenerProxy.errorOccurred(message,
                                   new ImagingException(message, ioe),
                                   this, false);
//      throw new
//    RuntimeException(JaiI18N.getString("BMPImageDecoder6"));
  }
View Full Code Here

                imSize - bytesRead);
      }
  } catch (IOException ioe) {
            String message = JaiI18N.getString("BMPImageDecoder6");
            ImagingListenerProxy.errorOccurred(message,
                                   new ImagingException(message, ioe),
                                   this, false);
//      throw new
//    RuntimeException(JaiI18N.getString("BMPImageDecoder6"));
  }
View Full Code Here

      }
  } catch (IOException ioe) {
      // throw new RuntimeException(JaiI18N.getString("BMPImageDecoder6"));
            String message = JaiI18N.getString("BMPImageDecoder4");
            ImagingListenerProxy.errorOccurred(message,
                                   new ImagingException(message, ioe),
                                   this, false);
//      throw new RuntimeException(ioe.getMessage());
  }

  int l=0, count;
View Full Code Here

    }
      }
  } catch (IOException ioe) {
            String message = JaiI18N.getString("BMPImageDecoder6");
            ImagingListenerProxy.errorOccurred(message,
                                   new ImagingException(message, ioe),
                                   this, false);
//      throw new RuntimeException(JaiI18N.getString("BMPImageDecoder6"));
  }
    }
View Full Code Here

    }
      }
  } catch (IOException ioe) {
            String message = JaiI18N.getString("BMPImageDecoder6");
            ImagingListenerProxy.errorOccurred(message,
                                   new ImagingException(message, ioe),
                                   this, false);
//      throw new RuntimeException(JaiI18N.getString("BMPImageDecoder6"));
  }
    }
View Full Code Here

TOP

Related Classes of com.sun.media.jai.codecimpl.util.ImagingException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.