1

I need Your help in generating offscreen images from graphics class and converting them to binary data without setting them visible on screen. I want to generate large amounts of labels and send them to a printer as binary data. If i create the image, show it on screen and then send it, everything is ok, but i generate 100 labels in one minute and it is annoying when they flicker on the screen of my java aplication. I want it to be generated by a seperate thread, without visible efects.
If i don't show them, the labels are send black. I tried to generate them, and then show them off screen, that did not match my expectations. Is there a way to generate "invisible" images from Graphics2d?? or Is there another way You could suggest me?

Thank You in advance Qba

package
  • 4,741
  • 1
  • 25
  • 35
Qba
  • 21
  • 2

1 Answers1

2

You can use a BufferedImage and use getGraphics() to get hold of a Graphics2D object that paints onto this image.

If you're after painting GUI components (if your "label" refers to JLabel for instance) you could have a look at these questions:

Community
  • 1
  • 1
aioobe
  • 413,195
  • 112
  • 811
  • 826
  • Thank You for Your response. I already use a BufferedImage and getGraphics(). This is my method: – Qba May 25 '12 at 11:48
  • Thank You for Your response. I already use a BufferedImage and getGraphics(). I have a class that extend a JPanel, I draw some graphics on it in the paint method, then I create a new BufferedImage and then a use image.getGraphics() to paint onto that image. But to launch the paint method i need to add it to a paintable component like a JDialog and make it visible on the screen, and I would prefer not to do that. I want to create an image from my elements like strings, barcodes, and somehow draw them to a bufferedImage without using the paint method or without makeing the component visible. Qba – Qba May 25 '12 at 11:55
  • *Why* do you need to make it visible on the screen? To launch the paint method? What do you need the paint method for? – aioobe May 25 '12 at 12:06