Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-06-2009, 08:10 AM
Member
 
Join Date: Apr 2009
Posts: 4
Rep Power: 0
hyz_zsu is on a distinguished road
Question 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?

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();
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 04-09-2009, 04:14 AM
hardwired's Avatar
Senior Member
 
Join Date: Jul 2007
Posts: 1,577
Rep Power: 4
hardwired is on a distinguished road
Default
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.
Code:
g.setBackground(Color.WHITE);
g.fillRect(0,0,w,h);
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Background image leiferouis New To Java 9 03-08-2009 06:49 PM
Image as background Java.child AWT / Swing 2 10-03-2008 12:37 AM
Background Image of Applet BangJava Java Applets 5 09-17-2008 03:45 PM
Center background image Floetic AWT / Swing 1 04-24-2008 06:50 PM
Why this image background is black ? samson Java 2D 1 07-17-2007 05:24 AM


All times are GMT +2. The time now is 01:17 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org