tag:blogger.com,1999:blog-5032116502138394246.post3437253369655162409..comments2023-06-18T11:59:59.564-07:00Comments on Keilly: Clear a BufferedImage in JavaNeil Cochranehttp://www.blogger.com/profile/15794968211428864510noreply@blogger.comBlogger18125tag:blogger.com,1999:blog-5032116502138394246.post-89396940985075183652013-08-24T11:53:02.152-07:002013-08-24T11:53:02.152-07:00Thank you so much. I spent a lot of days to solve ...Thank you so much. I spent a lot of days to solve my trouble with repainting on transparent background. Thank you very, very, very much!!!!Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5032116502138394246.post-79135157742355737992013-06-28T20:44:57.432-07:002013-06-28T20:44:57.432-07:00hi, what type is the bufferedImage? When i use &qu...hi, what type is the bufferedImage? When i use "TYPE_INT_ARGB", it doesn't work, but when i use "TYPE_INT_BGR", it works. Why?Anonymoushttps://www.blogger.com/profile/16442368002303056046noreply@blogger.comtag:blogger.com,1999:blog-5032116502138394246.post-64762630622537551082012-01-26T03:30:33.295-08:002012-01-26T03:30:33.295-08:00Thanks. Brilliant tip.Thanks. Brilliant tip.Stoodlesnoreply@blogger.comtag:blogger.com,1999:blog-5032116502138394246.post-45978885282211122352011-09-26T08:16:45.282-07:002011-09-26T08:16:45.282-07:00Dude, thanks a bunch.Dude, thanks a bunch.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5032116502138394246.post-22232873158737191122011-05-18T07:09:22.743-07:002011-05-18T07:09:22.743-07:00Great post. Helped a lot. Thanks.Great post. Helped a lot. Thanks.Anonymoushttps://www.blogger.com/profile/06896320607009622709noreply@blogger.comtag:blogger.com,1999:blog-5032116502138394246.post-17488886728362947392011-04-03T17:28:42.554-07:002011-04-03T17:28:42.554-07:00Thanks. Really appreciate your article. I was stuc...Thanks. Really appreciate your article. I was stuck on this for many days.<br /><br />Also, in my case I had to redraw the image and some new shapes. For this I did the following<br /><br />Graphics2D newgraphics = panel1.getGraphics();<br /><br />Composite backup=newgraphics.getComposite();<br /><br />//set the composite to clear as per the Keilly's code<br />newgraphics.setComposite(...)<br />...<br />...<br />//Fill the cleared area with rectangle and then<br /><br />newgraphics.setComposite(backup);<br /><br />//and then re-load the image from a file and draw it -><br />reloadimage();<br />newgraphics.drawImage(...)<br />panel1.updateUI();<br /><br /><br /><br /><br />Thanks, Keilly once again for sharing the articleAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-5032116502138394246.post-63021792151108543682010-07-12T17:10:31.484-07:002010-07-12T17:10:31.484-07:00Most likely because the composite is still set to ...Most likely because the composite is still set to be clearing shapes rather than filling in.<br />Try setting the composite back to something normal - easiest way to do this is just to create a new Graphics2D from the image and paint on thatNeil Cochranehttps://www.blogger.com/profile/15794968211428864510noreply@blogger.comtag:blogger.com,1999:blog-5032116502138394246.post-64057663342472817872010-07-12T12:39:43.246-07:002010-07-12T12:39:43.246-07:00I am unable to paint new shapes after i have clear...I am unable to paint new shapes after i have cleared part or all of my BufferedImage.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5032116502138394246.post-85930777975208132302010-07-12T09:17:48.522-07:002010-07-12T09:17:48.522-07:00Just set the rect to the area you want to clear.Just set the rect to the area you want to clear.Neil Cochranehttps://www.blogger.com/profile/15794968211428864510noreply@blogger.comtag:blogger.com,1999:blog-5032116502138394246.post-78175353425444633442010-07-12T09:03:35.553-07:002010-07-12T09:03:35.553-07:00How would you do this to only a section of your im...How would you do this to only a section of your image and not the entire image?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5032116502138394246.post-5146935170739636582010-05-10T10:16:46.233-07:002010-05-10T10:16:46.233-07:00To the previous poster: The javadoc for Graphics.c...To the previous poster: The javadoc for Graphics.clearRect(...) says it fills a rectangle with the current background color. This sounds quite different to really clearing an image.Neil Cochranehttps://www.blogger.com/profile/15794968211428864510noreply@blogger.comtag:blogger.com,1999:blog-5032116502138394246.post-80875808180063299712010-05-08T09:03:53.841-07:002010-05-08T09:03:53.841-07:00Very good, but you can also
clear an image with fo...Very good, but you can also<br />clear an image with following code:<br />yourBufferedImage.createGraphics ().clearRect (0, 0, width, height);Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5032116502138394246.post-72320289281867725772010-03-06T23:31:43.186-08:002010-03-06T23:31:43.186-08:00Wow. My search has finally ended! :DWow. My search has finally ended! :DUnknownhttps://www.blogger.com/profile/08880849335161165878noreply@blogger.comtag:blogger.com,1999:blog-5032116502138394246.post-63776275766065468542009-10-19T12:06:21.636-07:002009-10-19T12:06:21.636-07:00thank you, very very usefullythank you, very very usefullyUnknownhttps://www.blogger.com/profile/15240435589287067521noreply@blogger.comtag:blogger.com,1999:blog-5032116502138394246.post-48158045535916330982009-07-30T02:46:16.289-07:002009-07-30T02:46:16.289-07:00Thank you. You have saved me a lot of time by sha...Thank you. You have saved me a lot of time by sharing that information.Randolf Richardsonhttp://www.lumbercartel.ca/noreply@blogger.comtag:blogger.com,1999:blog-5032116502138394246.post-80665498336907828302009-02-27T22:14:00.000-08:002009-02-27T22:14:00.000-08:0011/10 for a great tip ! That's saved me a huge amo...11/10 for a great tip ! That's saved me a huge amount of time and angst. ThankyouAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-5032116502138394246.post-65427468893057431902008-05-01T10:07:00.000-07:002008-05-01T10:07:00.000-07:00great, exactly what i was searching for. i love yo...great, exactly what i was searching for. i love you!knuspermagierhttps://www.blogger.com/profile/11305760344821084558noreply@blogger.comtag:blogger.com,1999:blog-5032116502138394246.post-57325951908336248732007-10-31T16:17:00.000-07:002007-10-31T16:17:00.000-07:00this is exactly what i needed to solve my problem....this is exactly what i needed to solve my problem. thank you.Anonymousnoreply@blogger.com