Results 1 to 2 of 2
- 04-06-2009, 07:10 AM #1
Member
- Join Date
- Apr 2009
- Posts
- 4
- Rep Power
- 0
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?
Java Code:// 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.
Java Code:g.setBackground(Color.WHITE); g.fillRect(0,0,w,h);
Similar Threads
-
Background Image of Applet
By BangJava in forum Java AppletsReplies: 8Last Post: 11-24-2010, 05:48 AM -
Background image
By leiferouis in forum New To JavaReplies: 9Last Post: 03-08-2009, 05:49 PM -
Image as background
By Java.child in forum AWT / SwingReplies: 2Last Post: 10-02-2008, 11:37 PM -
Center background image
By Floetic in forum AWT / SwingReplies: 1Last Post: 04-24-2008, 05:50 PM -
Why this image background is black ?
By samson in forum Java 2DReplies: 1Last Post: 07-17-2007, 04:24 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks