BufferedImage « Graphics « Java Swing Q&A





1. BufferedImage's getSubimage performance    stackoverflow.com

I'm working on a Java 2D rendering program (running on 1.6.0_11), which uses external images for its UI rendering. These large images contain several UI graphics parts at the same time, ...

2. Resize JComponent for file export    stackoverflow.com

I have a JPanel upon which I draw a number of custom-written JComponents using the usual 'paintComponent(Graphics g)' method. I use a JLayeredPane to control the display order of the ...

3. Java/Swing offscreen rendering (Cobra HTMLPanel -> BufferedImage) Problem: Component doesn't finish redrawing first    stackoverflow.com

I'm trying to render the contents of a the Java/Swing Cobra HTML renderer to an offscreen BufferedImage, for use elsewhere in my app:

 slideViewPanel.setDocument(document, rendererContext);
 BufferedImage test = new ...

4. BufferedImage.getGraphics() resulting in memory leak, is there a fix?    stackoverflow.com

I'm having problem with some framework API calling BufferedImage.getGraphics() method and thus causing memory leak. What this method does is that it always calls BufferedImage.createGraphics(). On a windows machine, createGraphics() is ...

5. Trouble with BufferedImage & ImageObserver in Clojure/Swing/Java    stackoverflow.com

I've been trying for hours to get my drawing method to work by drawing in a BufferedImage stored in a Clojure ref, and then to have that painted onto the component ...

6. apply filter on selected Area of BufferedImage    stackoverflow.com

i want apply some Filters on BufferedImage but don't apply these filters on whole of bufferedImage , i need apply filter on Rectangle , ellipse , freehand selection of BufferedImage.anybody have idea ? ...

7. How do I desaturate a BufferedImage in Java?    stackoverflow.com

What's the simplest way to desaturate a BufferedImage?

8. Working my way arround repaint() in Java    stackoverflow.com

I'm planning to write a simple spaceshooter. I have read that the repaint() method is only a request, and it doesn't execute every time it's called. I believe I'm noticing the ...

9. Resizing BufferedImage    stackoverflow.com

i would like to resize a BufferedImage that is draw using the Graphics drawing method with AffineTransform object.

        AffineTransform at = new AffineTransform();
  ...





10. Passing swing screen to another Java application. Does swing update its screen when minimized?    stackoverflow.com

my question is two folds: Can you pass the screen of one Swing application to another Java program so the latter can act as a "viewer" of the former? Perhaps by passing ...

11. Using java, how can I make a method taking in a BufferedImage, rotate it, and return a BufferedImage ( with correct width / height )    stackoverflow.com

I have been looking up a lot of examples, every time I try, my image becomes offset, and also not rotated by the degree I am looking for. I have a class ...

13. Scaled BufferedImage woes    coderanch.com

Okay, here's a tuffy: At work I'm creating an app that displays binary data on a raster display. I am using a BufferedImage to store the raster that I create by hand using information from a byte array (the format of the data and how it is processed is unimportant to the question). Since the user will be looking at data ...

14. maintain a BufferedImage as it is.........    coderanch.com

import java.awt.*; import java.awt.image.*; import javax.swing.*; public class ScreenViewer extends JFrame { public static void main( String[] arg ) { new ScreenViewer(); } public ScreenViewer() { super( "Screen Viewer" ); setDefaultCloseOperation( EXIT_ON_CLOSE ); setSize( 400, 400 ); try { Robot robot = new Robot(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Rectangle screen = new Rectangle( screenSize ); BufferedImage i = robot.createScreenCapture( screen ); ...

15. BufferedImage to System Clipboard    coderanch.com

Yep... it's possible... import java.awt.*; import java.awt.datatransfer.*; import java.awt.image.*; import java.io.*; public class ClipboardImage implements ClipboardOwner { public ClipboardImage() { try { Robot robot = new Robot(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Rectangle screen = new Rectangle( screenSize ); BufferedImage i = robot.createScreenCapture( screen ); TransferableImage trans = new TransferableImage( i ); Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard(); c.setContents( trans, this ); } catch ...

16. How to transfer a bufferedImage Object?    coderanch.com

Here's some really short examples of this... The client... import java.awt.*; import java.awt.image.*; import java.io.*; import java.net.*; import javax.imageio.*; import javax.swing.ImageIcon; public class ScreenCapturer { private Robot robot; public ScreenCapturer() throws AWTException { robot = new Robot(); } public BufferedImage getScreen() { Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Rectangle screen = new Rectangle( screenSize ); BufferedImage i = robot.createScreenCapture( screen ); return i; ...





17. BufferedImage ?    coderanch.com

all i am attempting to draw a polygon (in this case a pentagon) and have succeeded in getting it drawn and displayed on JPanel. trouble starts when i try to texture it so that the pentagon stands out from the rectangle it is painted on. please help. SEE "// TROUBLE STARTS HERE" comment compiler errors so far are MyPoly7A.java [47:1] cannot ...

18. Extending BufferedImage    coderanch.com

public class CrazyImage extends BufferedImage { public CrazyImage(int width, int height, int imageType) { super(width, height, imageType); } public static void main(String[] args) { CrazyImage src = new CrazyImage(200, 200, TYPE_INT_RGB); CrazyImage dst = new CrazyImage(200, 200, TYPE_INT_RGB); BufferedImageOp op = new AffineTransformOp(AffineTransform.getRotateInstance(Math.PI / 2), new RenderingHints(Collections.EMPTY_MAP)); CrazyImage result = (CrazyImage) op.filter(src, dst); System.out.println(result); } public String toString() { return "I'm ...

19. Flip/Rotate a BufferedImage    coderanch.com

20. Create BufferedImage    coderanch.com

21. BufferedImage size but not using int    coderanch.com

22. A question about BufferedImage class.    coderanch.com

23. Modifying a BufferedImage in a JComponent    coderanch.com

I am confused. I have a JComponent whose paintComponent draws a BufferedImage. The constructor just uses ImageIO to read the image ( .gif) from a file. Each color in the image is mapped and known. I have a mouse listener that detects a mouse click anywhere in the image, determines the what the color is, and is supposed to replace every ...

24. BufferedImage OutOfMemoryError    coderanch.com

25. BufferedImage / getRGB - problem    coderanch.com

Hi, What I want to do is to draw to BufferedImage via Graphics2D, and then copy all image by pixel. What I need is an ability to get pixel's color and it seems to work, but at least not in the way I suppose... There is the piece of code: BufferedImage dc = new BufferedImage(100, 20, BufferedImage.TYPE_INT_RGB); Graphics2D gg = dc.createGraphics(); ...

26. BufferedImage problem Mac OS X    coderanch.com

28. BufferedImage versus VolatileImage    coderanch.com

Thanks, thats exactly what I'm looking for. Volatile images seem kind of a hassle... at any moment the VRAM may be reclaimed, meaning if you had a separate thread perform the rendering, you have to instantiate and run it again (though I guess you could have a buffered image snapshot , but I'm don't know about performance issues and trade offs ...

29. byte[] to BufferedImage    coderanch.com

30. BufferedImage(s)    coderanch.com

31. Save transformed BufferedImage    coderanch.com

Hello community, I want to load an image from the hard disk, then rotate it by 90 and then save the rotated version to another file. However, the following doesn't work: import java.awt.image.*; import java.awt.*; import java.util.regex.*; import java.io.*; import javax.imageio.*; public class ImageRotate { public static void main(String[] args) throws IOException { BufferedImage im = ImageIO.read(new File("C:/a.png")); Graphics2D g = ...

32. BufferedImage TYPE_CUSTOM to TYPE_INT_ARGB    coderanch.com

Hey all, I'm trying to load a PNG image in that has transparency in it using JDK 1.6 u10 and manipulate the image data (pixels). The problem is if I do this: BufferedImage bi = null; try { bi = ImageIO.read(new File("test.png")); } catch (Exception e) { e.printStackTrace(); } System.out.println(bi.getType()); // == 0 Or this: BufferedImage bi = toBufferedImage(Toolkit.getDefaultToolkit().createImage("test.png")); System.out.println(original.getType()); // ...

33. Using the IndexColorModel class to create a BufferedImage    coderanch.com

Thanks Rob, i put your idea to the test with a very simple prototype which I include below. It worked fine. You know, the Sun API docs are brilliantly put together on some ways. Everything is so tight, but the downside is that they don't make it easy to figure out little things like "the default is transparent. I mean here ...

34. BufferedImage drawing problems    coderanch.com

Hello, when i initiate object of Grid it draws the grid, later when i want to clear image or other stuff it doesn't, for ex: clear() function which clears the image doesn't work !, any other function which draws any other stuff on the buffered image doesn't work also public class Grid extends JPanel { int startPositionX = 5; int startPositionY ...

35. Manipulating a BufferedImage for a dpi related problem....    coderanch.com

Hi, I am in the process of developing an app in java which takes screen shot on pressing a button on the app. I am getting the screen shot using java.awt.Robot class. Then i am passing the image to system clipboard using java.awt.datatransfer.Transferable object. Now the problem is when i try to paste that image in MS Word 2007, i get ...

36. how to convert a bufferedImage into a string    coderanch.com

public class ComponentAdapter extends MouseAdapter{ protected GlassPane glassPane; protected String action,str1; public ComponentAdapter(GlassPane glassPane, String action) { this.glassPane=glassPane; this.action=action; } public void mousePressed(MouseEvent e) { Component c = e.getComponent(); BufferedImage image = new BufferedImage(c.getWidth(), c.getHeight(), BufferedImage.TYPE_INT_ARGB); Graphics g = image.getGraphics(); c.paint(g); glassPane.setVisible(true); Point p = (Point) e.getPoint().clone(); SwingUtilities.convertPointToScreen(p, c); SwingUtilities.convertPointFromScreen(p, glassPane); glassPane.setPoint(p); glassPane.setImage(image); glassPane.repaint(); [color=green]for(int y=0; y

38. new BufferedImage OutOfMemoryError: Java heap space    java-forums.org

I have client server program that the client send a screen captured image continuously to the server warping the BufferedImage to ImageIcon and then the client will read the ImageIcon and save it to a file via ImageIO.write using BufferedImage. Now the problem is for ever received image a new BufferedImage will be created in the while loop, after 6 fream ...