Search in sources :

Example 6 with ImageDocument

use of org.intellij.images.editor.ImageDocument in project intellij-community by JetBrains.

the class ImageComponentUI method paint.

@Override
public void paint(Graphics g, JComponent c) {
    ImageComponent ic = (ImageComponent) c;
    if (ic != null) {
        ImageDocument document = ic.getDocument();
        BufferedImage image = document.getValue();
        if (image != null) {
            if (ic.isFileSizeVisible())
                paintBorder(g, ic);
            Dimension size = ic.getCanvasSize();
            Graphics igc = g.create(2, 2, size.width, size.height);
            // Transparency chessboard
            if (ic.isTransparencyChessboardVisible() && image.getTransparency() != Transparency.OPAQUE) {
                paintChessboard(igc, ic);
            }
            paintImage(igc, ic);
            // Grid
            if (ic.isGridVisible()) {
                paintGrid(igc, ic);
            }
            igc.dispose();
        }
    }
}
Also used : ImageDocument(org.intellij.images.editor.ImageDocument) BufferedImage(java.awt.image.BufferedImage)

Example 7 with ImageDocument

use of org.intellij.images.editor.ImageDocument in project intellij-community by JetBrains.

the class ImageComponentUI method paintImage.

private static void paintImage(Graphics g, ImageComponent ic) {
    ImageDocument document = ic.getDocument();
    Dimension size = ic.getCanvasSize();
    Graphics2D g2d = (Graphics2D) g;
    RenderingHints oldHints = g2d.getRenderingHints();
    BufferedImage image = ic.getDocument().getValue();
    Image renderer = document.getValue();
    if (size.width > image.getWidth() && size.height > image.getHeight()) {
        // disable any kind of source image manipulation when resizing
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
        g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
    } else {
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
    }
    g.drawImage(renderer, 0, 0, size.width, size.height, ic);
    g2d.setRenderingHints(oldHints);
}
Also used : BufferedImage(java.awt.image.BufferedImage) ImageDocument(org.intellij.images.editor.ImageDocument) BufferedImage(java.awt.image.BufferedImage)

Aggregations

BufferedImage (java.awt.image.BufferedImage)7 ImageDocument (org.intellij.images.editor.ImageDocument)7 ImageZoomModel (org.intellij.images.editor.ImageZoomModel)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 ColorModel (java.awt.image.ColorModel)1 Options (org.intellij.images.options.Options)1 ZoomOptions (org.intellij.images.options.ZoomOptions)1