Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>When you read an image with <code>ImageIO.read</code>, the colour model of the image file is retained. Since you read a PNG file, the problem may be that the source file is using an indexed colour model (palette) with few and perhaps not matching colours. Another problem may be that you have to enable anti-aliasing to avoid what you call pixelation.</p> <p>To avoid the colour model issue, you may have to create a new BufferedImage with e.g. an ARGB colour model, on which you first draw the loaded image and then the SVG graphic:</p> <pre><code>BufferedImage source = ImageIO.read(new File("imgToDrawOnto.png")); BufferedImage newImage = new BufferedImage( source.getWidth(), source.getHeight(), BufferedImage.TYPE_INT_ARGB); Graphics2D g = (Graphics2D)newImage.getGraphics(); g.drawImage(source, 0, 0, null); g.drawImage(circleImg, 100, 100, null); </code></pre> <p>To enable antialiasing, you can set the appropriate rendering hint on the <code>Graphics2D</code> object before drawing the other images:</p> <pre><code>g.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); </code></pre> <p>Optionally, you can also increase the antialiasing quality by enabling bilinear or bicubic interpolation:</p> <pre><code>g.setRenderingHint( RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); g.setRenderingHint( RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); </code></pre> <p>Added example image: <img src="https://i.stack.imgur.com/9JN8H.png" alt="enter image description here"></p>
    singulars
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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