Blank picture layers not resetting properly Java

Currently, I'm trying to make a panel for management of clips in the game I'm writing. When the player clicks the mouse, it will highlight the clips which are shown at the right of the screen, and if the player presses H on the keyboard, it will show onscreen a few help bullets for the player. When I draw these help strings, I draw a big gray square and then the text in black on top of it. When I try to clear it (by resetting the image it is all drawn onto to a blank image from my source files) all of the new things get drawn on top of the help screen instead of the help screen being cleared away.

public void refresh(){
        overImg = World.imageBank.getImage("blank", -1).getSubimage(0, 0, 400, 400);

The imageBank is exactly what it sounds like, a bank of images drawn in when the world is initialized. The getImage("blank", -1) returns a 1200, 1200 image I made that has a blank alpha channel, and I use a smaller version of it. This refresh method is called every time anything is pressed, and I can't understand why the image isn't reset. If there is any other code from this that I should provide that might be my problem, let me know.


For anyone else who runs into this same problem, my friend showed me the solution. When I pull in the image from my image bank, it isn't making a new image(which should have been obvious), its just giving a reference to the subimage portion of the original, which just means I was drawing onto my blank buffered image stored in the image bank. What should be done to prevent this is making a deep copy of the image, which needs to be done (more or less) like this.

public static BufferedImage deepCopyImage(BufferedImage bF){
        ColorModel cm = bF.getColorModel();
        boolean alphaPre = bF.isAlphaPremultiplied();
        WritableRaster wR = bF.copyData(null);
        return new BufferedImage(cm, wR, alphaPre, null);

Need Your Help

modal window will not open

jquery html jquery-templates

I am trying to add a modal window option to my webpage. It is a search page and when clicking on each search result the link will open up in a modal window. So Ive used the code from the page

Implementing jQuery function

javascript jquery

I have been trying to implement some JavaScript that would disable a submit button until all fields were filled. I found a great here: Disabling submit button until all fields have values. Hristo

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.