Results 1 to 2 of 2
- 04-06-2009, 07:10 AM #1Member
- Join Date
- Apr 2009
- Rep Power
How to set the background of binary image?
Hi All, I met a problem that can't set the background of the binary image which type is TYPE_BYTE_BINARY. It seem that the default color of image is black. I am try to set the background color as white. And I try to use the Graphics2D's setBackGround method, but it doesn't work. Can any body help?
// bi is a TYPE_BYTE_BINARY type BufferedImage BufferedImage rbi = new BufferedImage(w, h, bi.getType()); Graphics2D g = rbi.createGraphics(); // The java api indicated that the setBackground method is for RGB color model g.setBackground(Color.WHITE); // after rotation the magrin is filled by black color. g.rotate(Math.toRadians(angle), w / 2, h / 2); g.drawImage(bi, null, 0, 0); g.dispose();
- 04-09-2009, 03:14 AM #2
With the Component setBackground method java will use the specified color to fill in the background when it renders the component. Setting the color for the graphics context (g) only sets the color. You must tell it what to draw/fill with the color.
- By BangJava in forum Java AppletsReplies: 8Last Post: 11-24-2010, 06:48 AM
- By leiferouis in forum New To JavaReplies: 9Last Post: 03-08-2009, 06:49 PM
- By Java.child in forum AWT / SwingReplies: 2Last Post: 10-02-2008, 11:37 PM
- By Floetic in forum AWT / SwingReplies: 1Last Post: 04-24-2008, 05:50 PM
- By samson in forum Java 2DReplies: 1Last Post: 07-17-2007, 04:24 AM