private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); SerializableState smState = (SerializableState) in.readObject(); sampleModel = (SampleModel) smState.getObject(); SerializableState cmState = (SerializableState) in.readObject(); colorModel = (ColorModel) cmState.getObject(); } }
new SerializableRenderedImage( source, false, null, tileEncoding, null, null); final LogRecord record =
sampleImageFile)); ooStream = new ObjectOutputStream(outStream); sri = new SerializableRenderedImage(sampleImage, true); ooStream.writeObject(sri); } finally { sri.dispose(); } catch (Throwable e) {
try { storeSampleImage( sampleImageFile, sri.getSampleModel(), sri.getColorModel()); } catch (Exception e) { if (LOGGER.isLoggable(Level.WARNING)) { return new SampleImage(sri.getSampleModel(), sri.getColorModel()) .toBufferedImage(); } else {
/** * Returns the hash table "key" as a <code>Object</code> for this image. */ public static Object hashKey(RenderedImage owner) { BigInteger imageID = null; if (owner instanceof PlanarImage) imageID = (BigInteger) ((PlanarImage) owner).getImageID(); else if (owner instanceof SerializableRenderedImage) imageID = (BigInteger) ((SerializableRenderedImage) owner).getImageID(); if (imageID != null) { byte[] buf = imageID.toByteArray(); return new BigInteger(buf); } return owner.hashCode(); }
protected static byte[] getColorModelBinary(final ColorModel colorModel) { final SerializableState serializableColorModel = SerializerFactory.getState(colorModel); try { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(serializableColorModel); return baos.toByteArray(); } catch (final IOException e) { LOGGER.warn("Unable to serialize sample model", e); } return new byte[] {}; }
/** * Serializes this grid coverage. Before serialization, a {@linkplain SerializableRenderedImage * serializable rendered image} is created if it was not already done. */ private void writeObject(final ObjectOutputStream out) throws IOException { if (serializedImage == null) { RenderedImage source = image; while (source instanceof RenderedImageAdapter) { source = ((RenderedImageAdapter) source).getWrappedImage(); } if (source instanceof SerializableRenderedImage) { serializedImage = (SerializableRenderedImage) source; } else { if (tileEncoding == null) { tileEncoding = "gzip"; } serializedImage = new SerializableRenderedImage(source, false, null, tileEncoding, null, null); final LogRecord record = Loggings.format(Level.FINE, LoggingKeys.CREATED_SERIALIZABLE_IMAGE_$2, getName(), tileEncoding); record.setSourceClassName(GridCoverage2D.class.getName()); record.setSourceMethodName("writeObject"); record.setLoggerName(LOGGER.getName()); LOGGER.log(record); } } out.defaultWriteObject(); }
final SerializableState serializableColorModel = SerializerFactory.getState(palette); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); try {
/** * Serializes this grid coverage. Before serialization, a {@linkplain SerializableRenderedImage * serializable rendered image} is created if it was not already done. */ private void writeObject(final ObjectOutputStream out) throws IOException { ensureValid(); if (serializedImage == null) { RenderedImage source = image; while (source instanceof RenderedImageAdapter) { source = ((RenderedImageAdapter) source).getWrappedImage(); } if (source instanceof SerializableRenderedImage) { serializedImage = (SerializableRenderedImage) source; } else { if (tileEncoding == null) { tileEncoding = "gzip"; } serializedImage = new SerializableRenderedImage(source, false, null, tileEncoding, null, null); final LogRecord record = Logging.format(Level.FINE, LoggingKeys.CREATED_SERIALIZABLE_IMAGE_$2, getName(), tileEncoding); record.setSourceClassName(GridCoverage2D.class.getName()); record.setSourceMethodName("writeObject"); LOGGER.log(record); } } out.defaultWriteObject(); }