Note that there are some explanatory texts on larger screens.

plurals
  1. POJNI problem on OSX
    primarykey
    data
    text
    <p>I'm running into problems using AWT classes on OSX (10.5.8) with Java 6 (1.6.0_17 JVM: 14.3-b01-101). Trying to load java.awt.Dimension the code just freezes, this happens in Eclipse or from the command line. Anyone experiencing same problems ? The class is used by JAI in the following code: </p> <pre><code>public static byte[] resizeAsJPG(byte[] imageContent, double scale, float outputQuality) throws IllegalArgumentException, ImageOperationException { if (scale &lt;= 0) { throw new IllegalArgumentException("scale must be a positive number"); } if (outputQuality &lt;= 0 || outputQuality &gt; 1.0F) { throw new IllegalArgumentException("outputQuality must be between 0 and 1"); } try { // Fetch input image to seekable stream RenderedOp originalImage = getRenderedOp(imageContent); ((OpImage) originalImage.getRendering()).setTileCache(null); // Set scale parameters ParameterBlock saclingParams = new ParameterBlock(); saclingParams.addSource(originalImage); // The source image saclingParams.add(scale); // The xScale saclingParams.add(scale); // The yScale saclingParams.add(0.0); // The x translation saclingParams.add(0.0); // The y translation // RenderingHints renderingHints = new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); Map&lt;RenderingHints.Key, Object&gt; renderingHints = new HashMap&lt;RenderingHints.Key, Object&gt;(); renderingHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); renderingHints.put(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY); renderingHints.put(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY); renderingHints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // Scale using sub-sampling average which provides much better quality than bicubic interpolation RenderedOp scaledImage = JAI.create("SubsampleAverage", saclingParams, new RenderingHints(renderingHints)); // Encode scaled image as JPEG JPEGEncodeParam encodeParam = new JPEGEncodeParam(); encodeParam.setQuality(outputQuality); // Since we scale height and width (don't take into account the quality) int outputSizeEstimate = (int) (imageContent.length * scale * scale); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(outputSizeEstimate); ImageEncoder encoder = ImageCodec.createImageEncoder("JPEG", outputStream, encodeParam); encoder.encode(scaledImage); return outputStream.toByteArray(); } catch (Exception e) { throw new ImageOperationException(e.getMessage(), e); } </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload