Drawing HiDPI component to BufferedImage

Alexander Scherbatiy alexandr.scherbatiy at oracle.com
Fri Jan 24 04:39:26 PST 2014


  Hi Hendrik,

  The API that allows to create custom images for HiDPI displays is only 
under discussion now.
  It can be found in the thread: 
http://mail.openjdk.java.net/pipermail/awt-dev/2014-January/006775.html
  It also contains a link to the patch that allows SunGraphics2D class 
to correctly draw multi-resolution images.

  You can try to apply the patch to the JDK 9 and check that it works 
for your case.

  Thanks,
  Alexandr.

On 1/24/2014 12:05 PM, Hendrik Schreiber wrote:
> Hey,
>
> to animate a component, I usually draw it to a BufferedImage and then draw that image to the glass pane, where I can easily move it around without having to completely re-render the component all the time. Unfortunately, this technique does not work well on Retina/HiDPI displays, as I can't seem to be able to convince any components to render in high resolution to a BufferedImage.
>
> Is there a way to paint components to BufferedImages in high resolution?
> I'd like something like:
>
>          final Image image = component.createImage(component.getWidth(), component.getHeight());
>          component.paint(image.getGraphics());
>          // then go on to use the image...
>
> to work properly.
>
> Thanks,
>
> -hendrik



More information about the macosx-port-dev mailing list