Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
if (this.isDebugEnabled()) {
System.out.println("Writing sprite image to stream...");
}
if (output == null) {
throw new JXAException("WARNING ! No suitable image output stream to write ! " + this.toString());
}
try {
final Monitor monitor = this.renderableImpl.imageSynch;
synchronized (monitor) {
Dimension dim = null;
IIOMetadata metadata = null;
ImageWriter w = this.renderableImpl.io.getWriter(0, this.storeMime);
ImageWriteParam iwp = this.renderableImpl.io._getIWP(w, dim, this.storeMime, this._type, compressionQuality);
if (this.renderableImpl.io.IIOcontrollerEnabled) {
iwp.setController(SpriteIO.IIOControllers.get(this.storeMime));
if (iwp.hasController()) {
iwp.activateController();
}
}
ImageTypeSpecifier its = (this.renderableImpl.getStoreMode() & Sf3RenderableImpl.MODE_TILE) != 0 ? SpriteIO._getITS(this._type) : SpriteIO._getITS((RenderedImage) this.data);
if ((this.renderableImpl.getStoreMode() & Sf3RenderableImpl.MODE_TILE) == 0) {
if (!(this.data instanceof BufferedImage)) {
this.data = convertToBuffered(this.data, this.renderableImpl.io.obs, true);
}
if (((BufferedImage) this.data).getType() != this._type) {
this.data = convertToBuffered(this.data, this.renderableImpl.io.obs, true);
}
this.waitFor(this.data);
if (this.data == null) {
throw new JXAException("Sprite " + this.toString() + " had no data to write ");
}
if (!(this.data instanceof RenderedImage)) {
throw new JXAException("READ/WRITE ERROR : Sprite image isn't compatible with RenderedImage. " + this.data.getClass().getName());
}
dim = new Dimension(this.data.getWidth(this.renderableImpl.io.obs), this.data.getHeight(this.renderableImpl.io.obs));
this.renderableImpl.io.prepareWrite(dim, w, its, iwp, this.isUseIIOCacheEnabled(), output, this.data, this._type);
this.renderableImpl.io.writeToOutput(metadata, null, w, iwp, (BufferedImage) this.data);
} else {
ImageReader r = this.renderableImpl.io.getReader(0, this.tileMime);
r = this.renderableImpl.io.__getInput(this.tileSrc, this.innerResource, r, this.isUseIIOCacheEnabled());
dim = new Dimension(r.getWidth(0), r.getHeight(0));
if ((this.renderableImpl.io.prepareWrite(dim, w, its, iwp, this.isUseIIOCacheEnabled(), output, r, this._type) & _TILEFLAGS) == _TILEFLAGS) {
this.renderableImpl.io.writeToOutputTiled(dim, SpriteIO._WRITE_TILES_DIMENSION, w, iwp, r, this._type, null);
} else {
this.renderableImpl.io.writeToOutput(dim, w, iwp, r, this._type, null);
}
}
this.renderableImpl.io.endWrite(w);
if (this.isDebugEnabled()) {
System.out.println("writing is done.");
}
Thread.currentThread().setPriority(pty);
}
} catch (IllegalArgumentException ex) {
JXAException e = new JXAException(ex);
throw e;
}
}