Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can always create a <code>BufferedImage</code>, draw whatever needs to be grey-scaled to the <code>Graphics</code> object for that image using <code>bufferedImage.createGraphics()</code>, and then use the <code>javax.swing.GreyFilter</code> to create a grey-scaled copy of the image.</p> <p><a href="http://journals.ecs.soton.ac.uk/java/tutorial/ui/drawing/useFilter.html" rel="nofollow">This page shows you how to use a <code>Filter</code></a>.</p> <p>You might also want to compare your approach with SwingX's <code>BlendComposite</code>, which I expect does the same thing as you are doing. BlendComposite has a Saturation mode that would allow grey-scale. (It also has more modes.)</p> <p><a href="http://www.java2s.com/Code/Java/2D-Graphics-GUI/BlendCompositeDemo.htm" rel="nofollow">This page has a demo of BlendComposite.</a></p> <p>About efficiency, I expect there's no important difference between them, because there's intermediate steps, and from what I can see, complete copies of the image data with both. But if you retain the grey-scaled image using the first method I suggested, you can prevent recalculation of non-dynamic controls.</p> <p>If you do one of the above, the performance will be correct, and I expect that's what you really want.</p> <p>From your comments I guess you might just want to apply the effect to a component. For this you could use <code>JLayer</code>, only available in Java 7. From the <a href="http://docs.oracle.com/javase/7/docs/api/javax/swing/JLayer.html" rel="nofollow">Javadoc</a> there is an example of overlaying a translucent green. You could replace this with grey. If you want to use JLayer in previous versions of Java you could use <code>JXLayer</code>, part of the SwingX project.</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.
    3. 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