4

I have Java Swing application with maximized bounds for JFrame. The application is distributed as jar file up to now.

Initially for background image I have used some large arbitrary image file of png-format. And I do have a code which can load and set image as background for JFrame.

Now, I got a new image from designer in both cdr and png format. Png image is 5 by 4 thousand pixels now.

My requirements:

  1. to minimize image file size
  2. to support different screen resolutions

What would be the best option to meet requirements?

  • Resize file to 1920x1080 and keep as png, and resize at runtime to smaller images if needed according to resolution
  • Keep file as cdr or some other vector format. But I am not sure Java can easily read and convert it to BufferedImage
Roman C
  • 49,761
  • 33
  • 66
  • 176
Nikolay Kuznetsov
  • 9,467
  • 12
  • 55
  • 101

2 Answers2

2

If you have the opportunity to get the file in .svg this will fit your needs the best. You could then have a look at Apache's Batik library and its rasterizer to render the image.

Chris
  • 7,675
  • 8
  • 51
  • 101
1

What would be the best option to meet requirements?

Resize file to 1920x1080 and keep as png, and resize at runtime to smaller images ..

..or larger - time goes on, screen resolutions get bigger (& bigger)..

.. if needed according to resolution.

Yes. I think that is the best option.

Loading a library to render an SVG or EPS to BufferedImage at run-time seems like overkill for a BG image.

Deployment

The application is distributed as jar file..

Applications that use images often have a GUI. Does this app. have a GUI?

If so, it would be optimal to deploy it using Java Web Start.

The Jars for JWS can be downloaded lazily and programmatically, and are refreshed when updated, so the image should probably be in a separate Jar of its own to avoid downloading a new version every time there is a bug fix. When putting an image (or compressed media files in general - sound, video,..) use 'no compression'. Zip does nothing good for these already highly optimized, or at least very specialized, data formats.

Community
  • 1
  • 1
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
  • Yes, I have deployed it as JWS now. I have one background image and many small items, i.e. cards. Why it should it a jar, not just folder at server? Should I make two separate jars for bg and other images or package all in one? – Nikolay Kuznetsov Mar 01 '13 at 16:49