Example usage for java.awt RenderingHints KEY_ANTIALIASING

List of usage examples for java.awt RenderingHints KEY_ANTIALIASING

Introduction

In this page you can find the example usage for java.awt RenderingHints KEY_ANTIALIASING.

Prototype

Key KEY_ANTIALIASING

To view the source code for java.awt RenderingHints KEY_ANTIALIASING.

Click Source Link

Document

Antialiasing hint key.

Usage

From source file:com.fluidops.iwb.deepzoom.ImageLoader.java

private void generateIDCard(URI uri, Map<URI, Set<Value>> facets, String url, File file) {
    int width = 200;
    int height = 200;

    BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);

    Graphics2D ig2 = bi.createGraphics();
    ig2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    ig2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);

    /* Special ID card handling for certain entity types */

    /*  TODO: special images based on type
    if(facets.containsKey(RDF.TYPE)) {//from   ww  w . j a v  a  2 s  .co m
    Set<Value> facet = facets.get(RDF.TYPE);
            
    for(Value v : facet)
    {
        if(v.equals(Vocabulary.DCAT_DATASET))
        {
            
            Image img = null;
            try
            {
                img = ImageIO.read( new File( "webapps/ROOT/images/rdf.jpg" ) );
            }
            catch (MalformedURLException e)
            {
                logger.error(e.getMessage(), e);
            }
            catch (IOException e)
            {
                logger.error("Could not get image");
            }
            
            ig2.drawImage( img, 0, 0, null );        
            break;
        }
    }
    } */

    String label = EndpointImpl.api().getDataManager().getLabel(uri);
    Font font = new Font(Font.SANS_SERIF, Font.BOLD, 20);
    ig2.setFont(font);

    FontMetrics fontMetrics = ig2.getFontMetrics();
    int labelwidth = fontMetrics.stringWidth(label);
    if (labelwidth >= width) {
        int fontsize = 20 * width / labelwidth;
        font = new Font(Font.SANS_SERIF, Font.BOLD, fontsize);
        ig2.setFont(font);
        fontMetrics = ig2.getFontMetrics();
    }

    int x = (width - fontMetrics.stringWidth(label)) / 2;
    int y = (fontMetrics.getAscent() + (height - (fontMetrics.getAscent() + fontMetrics.getDescent())) / 2);

    ig2.setPaint(Color.black);

    ig2.drawString(label, x, y);

    BufferedOutputStream out;
    try {
        out = new BufferedOutputStream(new FileOutputStream(file));
        ImageIO.write(bi, "PNG", out);
        out.flush();
        out.close();

    } catch (IOException e) {
        logger.error(e.getMessage(), e);
    }
}

From source file:VASSAL.counters.Labeler.java

public static void drawLabel(Graphics g, String text, int x, int y, Font f, int hAlign, int vAlign,
        Color fgColor, Color bgColor, Color borderColor) {
    g.setFont(f);// www . j  a v a2s  .co m
    final int width = g.getFontMetrics().stringWidth(text + "  ");
    final int height = g.getFontMetrics().getHeight();
    int x0 = x;
    int y0 = y;
    switch (hAlign) {
    case CENTER:
        x0 = x - width / 2;
        break;
    case LEFT:
        x0 = x - width;
        break;
    }
    switch (vAlign) {
    case CENTER:
        y0 = y - height / 2;
        break;
    case BOTTOM:
        y0 = y - height;
        break;
    }
    if (bgColor != null) {
        g.setColor(bgColor);
        g.fillRect(x0, y0, width, height);
    }
    if (borderColor != null) {
        g.setColor(borderColor);
        g.drawRect(x0, y0, width, height);
    }
    g.setColor(fgColor);
    ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g.drawString(" " + text + " ", x0, y0 + g.getFontMetrics().getHeight() - g.getFontMetrics().getDescent());
}

From source file:ch.entwine.weblounge.preview.jai.JAIPreviewGenerator.java

/**
 * Resizes the given image to what is defined by the image style and writes
 * the result to the output stream.// w  ww.  j ava2s  . c o  m
 * 
 * @param is
 *          the input stream
 * @param os
 *          the output stream
 * @param format
 *          the image format
 * @param style
 *          the style
 * @throws IllegalArgumentException
 *           if the image is in an unsupported format
 * @throws IllegalArgumentException
 *           if the input stream is empty
 * @throws IOException
 *           if reading from or writing to the stream fails
 * @throws OutOfMemoryError
 *           if the image is too large to be processed in memory
 */
private void style(InputStream is, OutputStream os, String format, ImageStyle style)
        throws IllegalArgumentException, IOException, OutOfMemoryError {

    // Does the input stream contain any data?
    if (is.available() == 0)
        throw new IllegalArgumentException("Empty input stream was passed to image styling");

    // Do we need to do any work at all?
    if (style == null || ImageScalingMode.None.equals(style.getScalingMode())) {
        logger.trace("No scaling needed, performing a noop stream copy");
        IOUtils.copy(is, os);
        return;
    }

    SeekableStream seekableInputStream = null;
    RenderedOp image = null;
    try {
        // Load the image from the given input stream
        seekableInputStream = new FileCacheSeekableStream(is);
        image = JAI.create("stream", seekableInputStream);
        if (image == null)
            throw new IOException("Error reading image from input stream");

        // Get the original image size
        int imageWidth = image.getWidth();
        int imageHeight = image.getHeight();

        // Resizing
        float scale = ImageStyleUtils.getScale(imageWidth, imageHeight, style);

        RenderingHints scaleHints = new RenderingHints(RenderingHints.KEY_ANTIALIASING,
                RenderingHints.VALUE_ANTIALIAS_ON);
        scaleHints.put(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
        scaleHints.put(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
        scaleHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);

        int scaledWidth = Math.round(scale * image.getWidth());
        int scaledHeight = Math.round(scale * image.getHeight());
        int cropX = 0;
        int cropY = 0;

        // If either one of scaledWidth or scaledHeight is < 1.0, then
        // the scale needs to be adapted to scale to 1.0 exactly and accomplish
        // the rest by cropping.

        if (scaledWidth < 1.0f) {
            scale = 1.0f / imageWidth;
            scaledWidth = 1;
            cropY = imageHeight - scaledHeight;
            scaledHeight = Math.round(imageHeight * scale);
        } else if (scaledHeight < 1.0f) {
            scale = 1.0f / imageHeight;
            scaledHeight = 1;
            cropX = imageWidth - scaledWidth;
            scaledWidth = Math.round(imageWidth * scale);
        }

        if (scale > 1.0) {
            ParameterBlock scaleParams = new ParameterBlock();
            scaleParams.addSource(image);
            scaleParams.add(scale).add(scale).add(0.0f).add(0.0f);
            scaleParams.add(Interpolation.getInstance(Interpolation.INTERP_BICUBIC_2));
            image = JAI.create("scale", scaleParams, scaleHints);
        } else if (scale < 1.0) {
            ParameterBlock subsampleAverageParams = new ParameterBlock();
            subsampleAverageParams.addSource(image);
            subsampleAverageParams.add(Double.valueOf(scale));
            subsampleAverageParams.add(Double.valueOf(scale));
            image = JAI.create("subsampleaverage", subsampleAverageParams, scaleHints);
        }

        // Cropping
        cropX = (int) Math.max(cropX,
                (float) Math.ceil(ImageStyleUtils.getCropX(scaledWidth, scaledHeight, style)));
        cropY = (int) Math.max(cropY,
                (float) Math.ceil(ImageStyleUtils.getCropY(scaledWidth, scaledHeight, style)));

        if ((cropX > 0 && Math.floor(cropX / 2.0f) > 0) || (cropY > 0 && Math.floor(cropY / 2.0f) > 0)) {

            ParameterBlock cropTopLeftParams = new ParameterBlock();
            cropTopLeftParams.addSource(image);
            cropTopLeftParams.add(cropX > 0 ? ((float) Math.floor(cropX / 2.0f)) : 0.0f);
            cropTopLeftParams.add(cropY > 0 ? ((float) Math.floor(cropY / 2.0f)) : 0.0f);
            cropTopLeftParams.add(scaledWidth - Math.max(cropX, 0.0f)); // width
            cropTopLeftParams.add(scaledHeight - Math.max(cropY, 0.0f)); // height

            RenderingHints croppingHints = new RenderingHints(JAI.KEY_BORDER_EXTENDER,
                    BorderExtender.createInstance(BorderExtender.BORDER_COPY));

            image = JAI.create("crop", cropTopLeftParams, croppingHints);
        }

        // Write resized/cropped image encoded as JPEG to the output stream
        ParameterBlock encodeParams = new ParameterBlock();
        encodeParams.addSource(image);
        encodeParams.add(os);
        encodeParams.add("jpeg");
        JAI.create("encode", encodeParams);

    } catch (Throwable t) {
        if (t.getClass().getName().contains("ImageFormat")) {
            throw new IllegalArgumentException(t.getMessage());
        }
    } finally {
        IOUtils.closeQuietly(seekableInputStream);
        if (image != null)
            image.dispose();
    }
}

From source file:org.uva.itast.blended.omr.pages.PDFPageImage.java

/**
 * @param x//from  w  w w.  jav a  2  s. co  m
 * @param y
 * @param w
 * @param h
 * @return
 */
private SubImage getSubimageWithPartialRendering(Rectangle2D rect, int imageType) {
    double pageHeight = getPage().getHeight();
    // Area in pixels according to preferred resolution
    Point upperLeft = toPixels(rect.getX(), rect.getY());

    Rectangle imageBBox = this.toPixels(rect); // subImage Bounding Box in pixels      
    Rectangle2D pdfAreaBBox = toPDFUnits(imageBBox); // subImage Bounding Box in PDF units

    Rectangle imageSize = new Rectangle(imageBBox.width, imageBBox.height); // subImage Size in pixels

    Rectangle2D clippingArea = new Rectangle(); // area of interest in the PDF
    clippingArea.setFrame(pdfAreaBBox.getX(), pageHeight - pdfAreaBBox.getY() - pdfAreaBBox.getHeight(), //PDF-Page coordinate space counts from bottomleft
            pdfAreaBBox.getWidth(), pdfAreaBBox.getHeight());

    SubImage img_pdf = new SubImage(imageSize.width, imageSize.height, imageType);
    // se configura la imagen con las medidas necesarias

    Graphics2D g2 = img_pdf.createGraphics(); // se crea un objeto grfico en dos dimensiones
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); // prefer to get sharp edges

    PDFRenderer renderer = new PDFRenderer(getPage(), g2, imageSize, clippingArea, Color.RED); // se renderiza la imgen 
    try {
        getPage().waitForFinish();
    } catch (InterruptedException e) {
        e.printStackTrace();
        throw new RuntimeException(e);
    }
    renderer.run();

    img_pdf.setReference(upperLeft);
    img_pdf.setBoundingBox(imageBBox);

    return img_pdf;
}

From source file:net.sf.maltcms.common.charts.api.overlay.SelectionOverlay.java

/**
 *
 * @param g2/*from   w ww. j a  v a  2 s  .  c om*/
 * @param chartPanel
 */
@Override
public void paintOverlay(Graphics2D g2, ChartPanel chartPanel) {
    if (chartPanel.getChart().getAntiAlias()) {
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    }
    boolean isXYPlot = true;
    if (chartPanel.getChart().getPlot() instanceof XYPlot) {
        isXYPlot = true;
    } else if (chartPanel.getChart().getPlot() instanceof CategoryPlot) {
        isXYPlot = false;
    } else {
        throw new IllegalArgumentException("Can only handle XYPlot and CategoryPlot!");
    }
    if (isVisible()) {
        for (ISelection selection : mouseClickSelection) {
            if (selection.isVisible()) {
                Shape selectedEntity = null;
                if (isXYPlot) {
                    selectedEntity = chartPanel.getChart().getXYPlot().getRenderer()
                            .getItemShape(selection.getSeriesIndex(), selection.getItemIndex());
                } else {
                    selectedEntity = chartPanel.getChart().getCategoryPlot().getRenderer()
                            .getItemShape(selection.getSeriesIndex(), selection.getItemIndex());
                }
                if (selectedEntity == null) {
                    selectedEntity = generate(selection.getDataset(), selection.getSeriesIndex(),
                            selection.getItemIndex());
                }
                updateCrosshairs(selection.getDataset(), selection.getSeriesIndex(), selection.getItemIndex());
                Shape transformed = toView(selectedEntity, chartPanel, selection.getDataset(),
                        selection.getSeriesIndex(), selection.getItemIndex());
                drawEntity(transformed, g2, selectionFillColor, chartPanel, false);
            }
        }
        if (this.drawFlashSelection) {
            for (ISelection selection : flashSelection) {
                Shape selectedEntity = null;
                if (isXYPlot) {
                    selectedEntity = chartPanel.getChart().getXYPlot().getRenderer()
                            .getItemShape(selection.getSeriesIndex(), selection.getItemIndex());
                } else {
                    selectedEntity = chartPanel.getChart().getCategoryPlot().getRenderer()
                            .getItemShape(selection.getSeriesIndex(), selection.getItemIndex());
                }
                if (selectedEntity == null) {
                    selectedEntity = generate(selection.getDataset(), selection.getSeriesIndex(),
                            selection.getItemIndex());
                }
                Shape transformed = toView(selectedEntity, chartPanel, selection.getDataset(),
                        selection.getSeriesIndex(), selection.getItemIndex());
                drawEntity(transformed, g2, selectionFillColor.darker(), chartPanel, true);
            }
        }
        if (this.mouseHoverSelection != null && this.mouseHoverSelection.isVisible()) {
            Shape entity = null;
            if (isXYPlot) {
                entity = chartPanel.getChart().getXYPlot().getRenderer()
                        .getItemShape(mouseHoverSelection.getSeriesIndex(), mouseHoverSelection.getItemIndex());
            } else {
                entity = chartPanel.getChart().getCategoryPlot().getRenderer()
                        .getItemShape(mouseHoverSelection.getSeriesIndex(), mouseHoverSelection.getItemIndex());
            }
            if (entity == null) {
                entity = generate(mouseHoverSelection.getDataset(), mouseHoverSelection.getSeriesIndex(),
                        mouseHoverSelection.getItemIndex());
            }
            Shape transformed = toView(entity, chartPanel, mouseHoverSelection.getDataset(),
                    mouseHoverSelection.getSeriesIndex(), mouseHoverSelection.getItemIndex());
            drawEntity(transformed, g2, hoverFillColor, chartPanel, true);
        }
    }
    if (isXYPlot) {
        crosshairOverlay.paintOverlay(g2, chartPanel);
    }
}

From source file:org.forumj.web.servlet.post.SetAvatar.java

private BufferedImage renderImage(ImageSize destSize, int imgType, Image image) {
    BufferedImage thumbsImage = new BufferedImage(destSize.getWidth(), destSize.getHeight(), imgType);
    Graphics2D graphics2D = thumbsImage.createGraphics();
    graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
    graphics2D.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
    graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    graphics2D.drawImage(image, 0, 0, destSize.getWidth(), destSize.getHeight(), null);
    return thumbsImage;
}

From source file:org.apache.fop.render.bitmap.AbstractBitmapDocumentHandler.java

/** {@inheritDoc} */
public IFPainter startPageContent() throws IFException {
    int bitmapWidth;
    int bitmapHeight;
    double scale;
    Point2D offset = null;//from w w w. ja  va2 s  .c  o m
    if (targetBitmapSize != null) {
        //Fit the generated page proportionally into the given rectangle (in pixels)
        double scale2w = 1000 * targetBitmapSize.width / this.currentPageDimensions.getWidth();
        double scale2h = 1000 * targetBitmapSize.height / this.currentPageDimensions.getHeight();
        bitmapWidth = targetBitmapSize.width;
        bitmapHeight = targetBitmapSize.height;

        //Centering the page in the given bitmap
        offset = new Point2D.Double();
        if (scale2w < scale2h) {
            scale = scale2w;
            double h = this.currentPageDimensions.height * scale / 1000;
            offset.setLocation(0, (bitmapHeight - h) / 2.0);
        } else {
            scale = scale2h;
            double w = this.currentPageDimensions.width * scale / 1000;
            offset.setLocation((bitmapWidth - w) / 2.0, 0);
        }
    } else {
        //Normal case: just scale according to the target resolution
        scale = scaleFactor * getUserAgent().getTargetResolution()
                / FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION;
        bitmapWidth = (int) ((this.currentPageDimensions.width * scale / 1000f) + 0.5f);
        bitmapHeight = (int) ((this.currentPageDimensions.height * scale / 1000f) + 0.5f);
    }

    //Set up bitmap to paint on
    this.currentImage = createBufferedImage(bitmapWidth, bitmapHeight);
    Graphics2D graphics2D = this.currentImage.createGraphics();

    // draw page background
    if (!getSettings().hasTransparentPageBackground()) {
        graphics2D.setBackground(getSettings().getPageBackgroundColor());
        graphics2D.setPaint(getSettings().getPageBackgroundColor());
        graphics2D.fillRect(0, 0, bitmapWidth, bitmapHeight);
    }

    //Set rendering hints
    graphics2D.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
            RenderingHints.VALUE_FRACTIONALMETRICS_ON);
    if (getSettings().isAntiAliasingEnabled() && this.currentImage.getColorModel().getPixelSize() > 1) {
        graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        graphics2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
                RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    } else {
        graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
        graphics2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
                RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
    }
    if (getSettings().isQualityRenderingEnabled()) {
        graphics2D.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
    } else {
        graphics2D.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED);
    }
    graphics2D.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);

    //Set up initial coordinate system for the page
    if (offset != null) {
        graphics2D.translate(offset.getX(), offset.getY());
    }
    graphics2D.scale(scale / 1000f, scale / 1000f);

    return new Java2DPainter(graphics2D, getContext(), getFontInfo());
}

From source file:org.apache.pdflens.views.pagesview.PageDrawer.java

/**
 * Stroke the path.//from w w w  . j av a  2s .c o m
 *
 * @throws IOException If there is an IO error while stroking the path.
 */
public void strokePath() throws IOException {
    graphics.setColor(getGraphicsState().getStrokingColor().getJavaColor());
    graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
    graphics.setClip(getGraphicsState().getCurrentClippingPath());
    GeneralPath path = getLinePath();
    graphics.draw(path);
    path.reset();
}

From source file:com.kahlon.guard.controller.PersonImageManager.java

private BufferedImage resizeImageWithHint(BufferedImage originalImage, int type) {

    BufferedImage resizedImage = new BufferedImage(IMG_WIDTH, IMG_HEIGHT, type);
    Graphics2D g = resizedImage.createGraphics();
    g.drawImage(originalImage, 0, 0, IMG_WIDTH, IMG_HEIGHT, null);
    g.dispose();/*from   w  ww .  j  a  v  a 2s.c  o  m*/
    g.setComposite(AlphaComposite.Src);

    g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
    g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
    g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    return resizedImage;
}

From source file:org.pentaho.reporting.engine.classic.core.layout.output.RenderUtility.java

public static DefaultImageReference createImageFromDrawable(final DrawableWrapper drawable,
        final StrictBounds rect, final StyleSheet box, final OutputProcessorMetaData metaData) {
    final int imageWidth = (int) StrictGeomUtility.toExternalValue(rect.getWidth());
    final int imageHeight = (int) StrictGeomUtility.toExternalValue(rect.getHeight());

    if (imageWidth == 0 || imageHeight == 0) {
        return null;
    }/*from w w  w  .jav  a  2 s . c o m*/

    final double scale = RenderUtility.getNormalizationScale(metaData);
    final Image image = ImageUtils.createTransparentImage((int) (imageWidth * scale),
            (int) (imageHeight * scale));
    final Graphics2D g2 = (Graphics2D) image.getGraphics();

    final Object attribute = box.getStyleProperty(ElementStyleKeys.ANTI_ALIASING);
    if (attribute != null) {
        if (Boolean.TRUE.equals(attribute)) {
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        } else if (Boolean.FALSE.equals(attribute)) {
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
        }

    }
    if (RenderUtility.isFontSmooth(box, metaData)) {
        g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    } else {
        g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
    }

    g2.scale(scale, scale);
    // the clipping bounds are a sub-area of the whole drawable
    // we only want to print a certain area ...

    final String fontName = (String) box.getStyleProperty(TextStyleKeys.FONT);
    final int fontSize = box.getIntStyleProperty(TextStyleKeys.FONTSIZE, 8);
    final boolean bold = box.getBooleanStyleProperty(TextStyleKeys.BOLD);
    final boolean italics = box.getBooleanStyleProperty(TextStyleKeys.ITALIC);
    if (bold && italics) {
        g2.setFont(new Font(fontName, Font.BOLD | Font.ITALIC, fontSize));
    } else if (bold) {
        g2.setFont(new Font(fontName, Font.BOLD, fontSize));
    } else if (italics) {
        g2.setFont(new Font(fontName, Font.ITALIC, fontSize));
    } else {
        g2.setFont(new Font(fontName, Font.PLAIN, fontSize));
    }

    g2.setStroke((Stroke) box.getStyleProperty(ElementStyleKeys.STROKE));
    g2.setPaint((Paint) box.getStyleProperty(ElementStyleKeys.PAINT));

    drawable.draw(g2, new Rectangle2D.Double(0, 0, imageWidth, imageHeight));
    g2.dispose();

    try {
        return new DefaultImageReference(image);
    } catch (final IOException e1) {
        logger.warn("Unable to fully load a given image. (It should not happen here.)", e1);
        return null;
    }
}