Re: [JAVA2D] Windows XP SP2 dualview Rendering on one monitor only.
Hi Dimitri, Thanks a lot for your reply, greatly appreciated. it turn out it was in a deadlock I was accessing the graphicsConfiguration from different threads which is protected by a lock. [Message sent by forum member 'magpie' (magpie)] http://forums.java.net/jive/thread.jspa?messageID=290840 === To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message signoff JAVA2D-INTEREST. For general help, send email to [EMAIL PROTECTED] and include in the body of the message help.
Re: [JAVA2D] VolatileImage.validate() does not (always) work
Okay, so here is my code. Nothing special, I guess . . . . // Render Frame to volatile image. do { // Check if the viBackbuffer is still valid. graphicsConfiguration = this.getGraphicsConfiguration(); valCode = viBackbuffer.validate(graphicsConfiguration); if (valCode == VolatileImage.IMAGE_INCOMPATIBLE) { System.out.println(Image Incompatible . . . . ); System.out.println(Display Panel - Memory: + graphicsConfiguration.getDevice().getAvailableAcceleratedMemory()); viBackbuffer.flush(); viBackbuffer = graphicsConfiguration.createCompatibleVolatileImage(width, height); ImageCapabilities ic = viBackbuffer.getCapabilities(); if (ic.isAccelerated()) System.out.println(Backbuffer is ACCELERATED!); else System.out.println(Backbuffer is NOT accelerated . . . ); System.out.println(Display Panel - Memory: + graphicsConfiguration.getDevice().getAvailableAcceleratedMemory()); // Create graphic2D object from volatile images. g2dViBackbuffer = viBackbuffer.createGraphics(); g2dViBackbuffer.setBackground(Color.white); // Clear drawing surface of volatile images with color white. g2dViBackbuffer.clearRect(0, 0, width, height); } // my render Stuff } while (viBackbuffer.contentsLost()); [Message sent by forum member 'kiamur' (kiamur)] http://forums.java.net/jive/thread.jspa?messageID=290852 === To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message signoff JAVA2D-INTEREST. For general help, send email to [EMAIL PROTECTED] and include in the body of the message help.
Re: [JAVA2D] VolatileImage.validate() does not (always) work
Hi Dmitri, I have to apologize to the vaildate() method because it is the this.getGraphicsConfiguration that does not always realize that the image is located on a different screen. Now, I make a printout of the device ID each time I call this.getGraphicsConfiguration and although the dialoge is on a different screen, the graphic configuration tells me that it is on the old screen. After some more drags from one screen to the other, it finally realises the location change. . . . Maik [Message sent by forum member 'kiamur' (kiamur)] http://forums.java.net/jive/thread.jspa?messageID=290898 === To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message signoff JAVA2D-INTEREST. For general help, send email to [EMAIL PROTECTED] and include in the body of the message help.
Re: [JAVA2D] VolatileImage.validate() does not (always) work
I don't see much wrong with the code. See comments below. [EMAIL PROTECTED] wrote: Okay, so here is my code. Nothing special, I guess . . . . // Render Frame to volatile image. do { // Check if the viBackbuffer is still valid. graphicsConfiguration = this.getGraphicsConfiguration(); This graphicsConfguration field, are you sure it's not accessed (set) from some other thread? Also, could you print it out and see if it changes when you move the frame from one screen to another. Thanks, Dmitri valCode = viBackbuffer.validate(graphicsConfiguration); if (valCode == VolatileImage.IMAGE_INCOMPATIBLE) { System.out.println(Image Incompatible . . . . ); System.out.println(Display Panel - Memory: + graphicsConfiguration.getDevice().getAvailableAcceleratedMemory()); viBackbuffer.flush(); viBackbuffer = graphicsConfiguration.createCompatibleVolatileImage(width, height); ImageCapabilities ic = viBackbuffer.getCapabilities(); if (ic.isAccelerated()) System.out.println(Backbuffer is ACCELERATED!); else System.out.println(Backbuffer is NOT accelerated . . . ); System.out.println(Display Panel - Memory: + graphicsConfiguration.getDevice().getAvailableAcceleratedMemory()); // Create graphic2D object from volatile images. g2dViBackbuffer = viBackbuffer.createGraphics(); g2dViBackbuffer.setBackground(Color.white); // Clear drawing surface of volatile images with color white. g2dViBackbuffer.clearRect(0, 0, width, height); } // my render Stuff } while (viBackbuffer.contentsLost()); [Message sent by forum member 'kiamur' (kiamur)] http://forums.java.net/jive/thread.jspa?messageID=290852 === To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message signoff JAVA2D-INTEREST. For general help, send email to [EMAIL PROTECTED] and include in the body of the message help. === To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message signoff JAVA2D-INTEREST. For general help, send email to [EMAIL PROTECTED] and include in the body of the message help.
Re: [JAVA2D] VolatileImage.validate() does not (always) work
Could you please try this test on that system and see if the device in the title changes when you move the frame back and forth. [code] import java.awt.Frame; import java.awt.GraphicsDevice; import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; public class GraphicsConfigUpdateTest extends Frame { private GraphicsDevice currentDevice; public GraphicsConfigUpdateTest() { super(GraphicsConfigUpdateTest); this.addComponentListener(new ComponentAdapter() { public void componentMoved(ComponentEvent e) { GraphicsDevice gd = GraphicsConfigUpdateTest.this.getGraphicsConfiguration().getDevice(); if (gd != currentDevice) { GraphicsConfigUpdateTest.this.setTitle(Current device: + gd.toString()); currentDevice = gd; } } }); setSize(500, 100); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); } public static void main(String[] args) { GraphicsConfigUpdateTest test = new GraphicsConfigUpdateTest(); test.setVisible(true); } } [/code] Thanks, Dmitri [EMAIL PROTECTED] wrote: Hi Dmitri, I have to apologize to the vaildate() method because it is the this.getGraphicsConfiguration that does not always realize that the image is located on a different screen. Now, I make a printout of the device ID each time I call this.getGraphicsConfiguration and although the dialoge is on a different screen, the graphic configuration tells me that it is on the old screen. After some more drags from one screen to the other, it finally realises the location change. . . . Maik === To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message signoff JAVA2D-INTEREST. For general help, send email to [EMAIL PROTECTED] and include in the body of the message help.
Re: [JAVA2D] VolatileImage.validate() does not (always) work
Hi Dmitri, thanks for your effort! I will try your code on monday, when I am back at work. Anyway, to answer the questions from your first answer today: Firstly, yes, I am sure that no other thread updates my graphicConfiguration field. The other answer is that meanwhile I do print out the device ID of that field and, as I previously wrote, it does NOT always print out the correct ID on my target system. However, on my development system the same code DOES always print out the correct device ID. Could this be a performance issue because my target system is significally slower (but in my opinion not too slow) than my development system? Regards, Maik [Message sent by forum member 'kiamur' (kiamur)] http://forums.java.net/jive/thread.jspa?messageID=291024 === To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message signoff JAVA2D-INTEREST. For general help, send email to [EMAIL PROTECTED] and include in the body of the message help.
[JAVA2D] drawimage on a bilevel image does not work
I am using drawimage method to add a BufferedImage to another BufferedImage. The base image is a bilevel (white and black) and the added image is bilevel too. But in result, the added image just became a black frame in base image. Anyone has an idea? [Message sent by forum member 'jiezhang' (jiezhang)] http://forums.java.net/jive/thread.jspa?messageID=291046 === To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message signoff JAVA2D-INTEREST. For general help, send email to [EMAIL PROTECTED] and include in the body of the message help.
Re: [JAVA2D] drawimage exception
This problem is solved by constructing BufferedImage correctly. But still not sure why it is such exception thrown out. Can't find underline source code. [Message sent by forum member 'jiezhang' (jiezhang)] http://forums.java.net/jive/thread.jspa?messageID=291048 === To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message signoff JAVA2D-INTEREST. For general help, send email to [EMAIL PROTECTED] and include in the body of the message help.
Re: [JAVA2D] Universal image reading
Hi Adam, I haven't read through everything you've written here, but it sounds like you've already learned about the major players here - there are access methods at a number of levels - BufferedImage, Raster, DataBuffer, and some helper methods on SampleModel and ColorModel as well. The further down you dig, the faster things run since you are closer to the metal. [Keep in mind that digging the DataBuffer out of a Raster will defeat the managed image acceleration of BufferedImages in 1.6 and earlier - 1.7 will have a more flexible accounting scheme that lets you get the DataBuffer from a BufferedImage as long as you don't call the getData() method on the DataBuffer to get the raw Java array.] Note that the simplest, easiest to use, jack of all trades, accessor would be BufferedImage.getRGB(x, y) which returns a 32-bit ARGB value regardless of the underlying image type. It won't be as fast as analyzing the image and using the underlying methods that you've already investigated, but it lets you get the job done if you fall through the cracks of your image type detection code and it performs well enough for smaller tasks - grabbing the value of the occasional pixel... ...jim Adam Augusta wrote: So I've written a limited Java EPS creator for image files using BufferedImage and Image I/O, but it's not perfect. I need to determine if it's RGB, CMYK, or grayscale (including 1-bit BW), get the bits per component, collect the samples in per-pixel sequence in a certain order (RGB not BGR), and write my EPS. Oh, and if there's an alpha channel, I need to get those values and handle them specially. Ascertaining type: BufferedImage#getColorModel#getColorSpace#getType works for CMYK, but for 1-bit BW, it reports 8-bit RGB. BufferedImage#getType works for 1-bit BW (BufferedImage.TYPE_BYTE_BINARY), but not for CMYK (BufferedImage.TYPE_CUSTOM). So already, I'm forced to use a different strategy for different kinds of images. Do I have the right idea? Accessing sample information with a ColorModel is easy. final Object reusableDataArray = raster.getDataElements(x, y, null) final int[] reusableSampleArray = colorModel.getComponents(sampleArray, null, 0); final int bitsPerComponent = colorModel.getComponentSize(0); Accessing sample information from a Raster/SampleModel (TYPE_BYTE_BINARY) isn't quite so easy. BufferedImage#getType provides enough information to interpret the output of Raster#getPixel, but that means I have to write new logic for each #getType. So right now, through trial and error I'm typing up a list of BufferedImage.TYPE_*s that work well with ColorModel, and handling them consistently. For each types that don't work well with ColorModel, I'm writing special logic to interpret Raster#getPixel. Am I on the right track, or am I just making this hard for myself? === To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message signoff JAVA2D-INTEREST. For general help, send email to [EMAIL PROTECTED] and include in the body of the message help. === To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message signoff JAVA2D-INTEREST. For general help, send email to [EMAIL PROTECTED] and include in the body of the message help.
Re: [JAVA2D] Any way to make ANTIALIAS only use one color
You shouldn't be using Antialiased rendering on an Indexed image. Antialiasing requires the ability to choose a color that is N% of the way from the foreground to the background and store that color, but that color may not be in the colormap of an Indexed image. One could argue that we should have just ignored the AA hint for Indexed images since we may not find the intermediate colors that we need for the effect, but some images may actually have enough of the intermediate colors that we can render a nice effect even just restricting ourselves to the colors available in the colormap. So, we left it in and let the developer choose whether or not it is working well for their situation (which depends on the colormap that they are using). Since it doesn't seem to be working well with your particular colormap, my suggestion is to not use Antialiasing - or to come up with a better selection of colors in your colormap that provide enough intermediate colors for the AA algorithm to do its job... ...jim [EMAIL PROTECTED] wrote: If I draw into an Indexed bitmap, it seems that with antialias on it uses some kind of change color on edges algorithm. I am writing with one color, but the new pixels that antialiasing adds are not always the same color. I need to find a way to turn this off, and force it to use the same color. [Message sent by forum member 'keith198' (keith198)] http://forums.java.net/jive/thread.jspa?messageID=290418 === To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message signoff JAVA2D-INTEREST. For general help, send email to [EMAIL PROTECTED] and include in the body of the message help. === To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message signoff JAVA2D-INTEREST. For general help, send email to [EMAIL PROTECTED] and include in the body of the message help.
Re: [JAVA2D] drawimage on a bilevel image does not work
[EMAIL PROTECTED] wrote: I am using drawimage method to add a BufferedImage to another BufferedImage. The base image is a bilevel (white and black) and the added image is bilevel too. But in result, the added image just became a black frame in base image. Anyone has an idea? Please post a test reproducing the issue. Thanks, Dmitri === To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message signoff JAVA2D-INTEREST. For general help, send email to [EMAIL PROTECTED] and include in the body of the message help.
Re: [JAVA2D] drawimage on a bilevel image does not work
This is source code. How do I give images. import java.awt.image.BufferedImage; import java.awt.Graphics2D; import java.awt.AlphaComposite; import java.awt.Color; import java.awt.Font; import java.awt.RenderingHints; import java.awt.FontMetrics; import java.awt.geom.Rectangle2D; import java.awt.GraphicsEnvironment; import java.util.Iterator; import java.io.File; import javax.imageio.ImageIO; import javax.imageio.ImageReader; import javax.imageio.ImageWriter; import javax.imageio.ImageReadParam; import javax.imageio.ImageWriteParam; import javax.imageio.stream.ImageInputStream; import javax.imageio.stream.ImageOutputStream; import javax.imageio.ImageTypeSpecifier; import javax.imageio.IIOImage; public class Testdraw { public static void main(String [] args) { String inputFileName = /tmp/tkidifx3.tif; String addedFileName = /tmp/tkidiw33g.tif; String outputFileName = /tmp/tkidifx3w.tif; String outputFormat = tif; try { BufferedImage img = ImageIO.read((new File(inputFileName))); BufferedImage added_image = ImageIO.read((new File(addedFileName))); Graphics2D g2d = (Graphics2D) img.getGraphics(); //Create an alpha composite of 40% float opacity = 0.4f; AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, opacity); g2d.setComposite(alpha); g2d.drawImage(added_image, 200, 200, null); g2d.dispose(); Iterator writers = ImageIO.getImageWritersByFormatName(outputFormat); ImageWriter writer = null; while(writers.hasNext()) { writer = (ImageWriter)writers.next(); if(writer.getClass().getName().startsWith(com.sun)) { // Break on finding the core provider. break; } } if(writer == null) { throw new Exception(Cannot find core + outputFormat.toUpperCase() + writer!); } File f = new File(outputFileName); ImageOutputStream ios = ImageIO.createImageOutputStream(f); writer.setOutput(ios); ImageWriteParam wp = writer.getDefaultWriteParam(); writer.write(null,new IIOImage(img, null, null),wp); ios.close(); } catch (Throwable t) { t.printStackTrace(); } } } [Message sent by forum member 'jiezhang' (jiezhang)] http://forums.java.net/jive/thread.jspa?messageID=291060 === To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message signoff JAVA2D-INTEREST. For general help, send email to [EMAIL PROTECTED] and include in the body of the message help.
[JAVA2D] Should drawGlyphVector() honour rendering hints?
Should the drawGlyphVector() method in Graphics2D honour any current rendering hints such as RenderingHints.KEY_TEXT_ANTIALIASING? It appears not to be doing this. -- And loving it, -Qu0ll (Rare, not extinct) _ [EMAIL PROTECTED] [Replace the SixFour with numbers to email me] [Message sent by forum member 'qu0ll' (qu0ll)] http://forums.java.net/jive/thread.jspa?messageID=291062 === To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message signoff JAVA2D-INTEREST. For general help, send email to [EMAIL PROTECTED] and include in the body of the message help.
Re: [JAVA2D] Should drawGlyphVector() honour rendering hints?
[EMAIL PROTECTED] wrote: Should the drawGlyphVector() method in Graphics2D honour any current rendering hints such as RenderingHints.KEY_TEXT_ANTIALIASING? It appears not to be doing this. It gets that particular hint from the FontRenderContext that is used to create/layout the GlyphVector. -phil. === To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message signoff JAVA2D-INTEREST. For general help, send email to [EMAIL PROTECTED] and include in the body of the message help.