Call to Graphics2D.drawImage freezes OS

Whenever I call Graphics2D.drawImage(BufferedImage, BufferedImageOp, int, int), the entire system freezes for about 10 seconds, and then comes back as though nothing had happened. This is playing havoc with my code, because the paint routine is based on the system clock, and a freeze that long is very difficult to overcome. Here is the (abbreviated) code:
public static class Fade extends Transition
     FadeBIO f;
     protected Fade(PointAndClick p)
          super(p);
          f=new FadeBIO();
     public void draw(Graphics g, Registrar r,
          Component c, float p, Node no, Node nn)
          g./* draw back image */;
          Graphics2D gd=(Graphics2D)g;
          BufferedImage i=new BufferedImage(
               parent.W,parent.H,BufferedImage.TYPE_INT_ARGB);
          Graphics2D gi=i.createGraphics();
          ImageWrapper.GamePanel.drawImg(gi,parent,c,r,Color.BLUE,0,0,nn); // this fills the front image
          gd.drawImage(i,f.set(p),0,0); // this is the offending call
     private class FadeBIO implements BufferedImageOp
          int opacity=-1;
          FadeBIO set(float o)
               opacity=((int)(255*o)&0xff<<24)|0xffffff;
               return this;
          public BufferedImage filter(BufferedImage src, BufferedImage dst)
               int width=src.getWidth();
               int height=src.getHeight();
               WritableRaster srcRaster=src.getRaster();
               if (dst==null)
                    dst=createCompatibleDestImage(src,null);
               WritableRaster dstRaster=dst.getRaster();
               int[] inPixels=new int[width];
               for (int y=0;y<height;y++)
                    srcRaster.getDataElements(0,y,width,1,inPixels);
                    for (int x=0; x<width; x++)
                         inPixels[x]&=opacity;
                    dstRaster.setDataElements(0,y,width,1,inPixels);
               return dst;
          public BufferedImage createCompatibleDestImage(BufferedImage src,
               ColorModel dstCM)
               if (dstCM==null) dstCM=src.getColorModel();
               return new BufferedImage(dstCM,dstCM.
                    createCompatibleWritableRaster(src.getWidth(),src
                    .getHeight()),dstCM.isAlphaPremultiplied(),null);
          public Rectangle2D getBounds2D(BufferedImage src)
               return new Rectangle(0,0,src.getWidth(),src.getHeight());
          public Point2D getPoint2D(Point2D s, Point2D d)
               if (d==null) d=new Point2D.Double();
               d.setLocation(s.getX(),s.getY());
               return d;
          public RenderingHints getRenderingHints() {return null;}
}I'm pretty sure the BufferedImageOp checks out, and I am sure the call which freezes the system is the drawImage call. By the way, if anyone knows an alternative way to fade from one image to another, I'm open to suggestions (it's an animation, so it has to be fast).

At the moment, I don't really feel like writing the code verbatim to illustrate for you what I am attempting to explain. I think the confusion stems from a lack of understanding as to how the object references in your code interoperate. I will attempt to explain, and maybe code later if I feel up to it or if someone doesn't beat me to the punch. :) (It's Saturday, and I don't really want to spend it indoors coding....)
Your Graphics2D object _2DSkyImage is a reference to the Graphics2D object that is generated by the BufferedImage biSkyBuffer. Thus, when call any of the drawXXX() methods of your Graphics2D reference, it is drawing that information on to your image. If when you called the PixelGrabber constructor and gave it a reference to your BufferedImage, then, using the Graphics2D object drew something on your BufferedImage, it would (possibly) show up in the PixelGrabber. This is what we call a side-effect (though intended in this case). Once the image has been changed after you drew on it, you may have to tell the PixelGrabber object to reload the image data once it has been altered (via the Graphics2D object) so that it will track the changes.
The worst case scenario is that you'd have to reinstantiate the PixelGrabber object every time you altered the image, and if that was the case, I would consider ditching the implementation. However, you shouldn't have to do this because PixelGrabber does have methods that allow you to reload pixel data without reinstantiating.
Hopefully that clears it up. If not, let us know and we'll give it another shot. ;)
-Dok

Similar Messages

  • Odd behaviour in Graphics2D.drawImage - infinite loop?

    Hi,
    I have the following code inside an overriden paintComponent (JPanel):
    g2.drawImage(fc.getImage(),(int)fc.getSignificantPoint().getX(),
                                    (int)fc.getSignificantPoint().getY(), vioPanel);fc is just an object that is a wrapper for an image and vioPanel is the JPanel class that has been overriden (it's not this because the drawing on g2 is done outside the jpanel class)
    I'm getting some really strange behaviour that i can't explain: when the images are drawn i noticed they were flashing. so i put a system.out.println into the paintComponent method and it seems that calling the g2.drawImage method is causing the panel to be repainted constantly as if it is stuck in an infinite loop. Has anyone else experienced this? if so, do you know the solution?
    If it helps, if you replace the vioPanel variable with new JPanel() the looping stops.
    Cheers,
    jj

    hi,
    VioPanel is a simple class that overrides JPanel with some extra functionality. Essentially tho, it overrides the paintComponent method as shown below and calls a method of a different object that draws the shapes and images. I tried putting all the code in that method into paintComponent (i.e. classic overriding of paintComponent), but still get the same problem.
    public void paintComponent(Graphics g)
            super.paintComponent(g);
            dm.fireGraphics2DSequence();
        }The fireGraphics2DSequence method does all the drawing:
    public void fireGraphics2DSequence()
            Graphics2D g2 = getPanelGraphics();
            g2.scale(magniFactor, magniFactor);
            //separate entities out
            ArrayList features = getFeatures();
            ArrayList lines = getLines();
            //draw map entities (lines and hubs first)
            for(int i = 0; i < lines.size(); i++)
                //draws shapes, which works fine
            //draw nodes
            g2.setColor(Color.black);
            for(int i = 0; i < features.size(); i++)
                FeatureCircle fc = (FeatureCircle)features.get(i);
                if (fc.isTagged()) continue;
                g2.drawImage(fc.getImage(),(int)fc.getSignificantPoint().getX(),
                                    (int)fc.getSignificantPoint().getY(), vioPanel);
                //System.out.println("drawing "+i);
                if(entLabels) g2.drawString(fc.getName(),(float)fc.getSignificantPoint().getX(),
                                           (float)fc.getSignificantPoint().getY());
        }

  • Calls constantly failing / dropping / freezing.

    I recently moved flat, downgrading from a 100Mb to 10Mb internet connection, which should still be enough to maintain Skype calls (and is playing Netflix HD absolutely fine), but every time I make a video call it constantly drops and freezes. Whilst I'm on Skype, other internet actions become very slow / fail, and my mac (2013 Macbook Pro running OS X 10.9.4) disconnects from the wifi.
    Is there anything I can do to fix this? I know it's a problem on my end.

    It is a issue Microsoft/Skype does not want to address. Yesterday, I spent 2 hours reading users posts related to this issue.  Strangly, this issue is not resolved and surprisingly these issues are left untoched by forum moderators. 
    Users have posted these issues from all corners of the world and their numbers in thousands but Skype/Microsoft is turning deaf ear to their whole clientel. 
    I don't know how to reach Bill Gates to report this issue. Haha. I am sure he is not using Skype otherwise he might have fired whole team.
    I have seen some posts wherein they point fingers at ISP of the user. Are all ISPs in the world blocking Skype. Lol
    They know internally that the problem is within but don't want to annouce it which is very unfair. People have active subscriptions and paying money to talk to their loved ones and still going through pain and agony as they are unable to communicate with them. 
    What a mess!!!

  • Calling JFrame's pack() freezing my apps

    Hi all,
    When calling JFrame's pack() method my apps suddenly do not respond, I've tried to uninstall and reinstall the JDK but the problem persists. I use J2SDK 1.4.1_04. What's the problem ?
    Any help would be greatly appreciated.
    Setya

    Thanks for the response,
    My OS is Windows 2000 Advanced Server SP3, previously I've tried 1.3.1 & 1.4.0 which run fine, I've just downloaded the 1.4.1_04 and gave it a try. Actually my app does not completely freeze only the JFrame won't show up and no messages at all. This happens all of sudden after running fine for a couple of days.
    This also happens to the demo apps accompanying the JDK.
    Should I try 1.4.2 ? Because I don't want my PC stuffed with JDK I don't use. The reason why I can not keep up with the JDK release is because I have very limited access to internet so I can not download it as I want.
    Setya

  • COD (call of duty 4) freezes on new mac mini - Lion

    I hope someone can provide me some guidance..
    I just got my brand new mac mini with the following specs:
    2.5 ghz (i5)
    8GB RAM DDR3
    AMD Radeon HD 6630M 256MB
    OSX Lion 10.7
    When i play COD online in multiplayer mode (and only then) after about 2 minutes it starts to freeze for 4 seconds and unfreezes for 1 sec, recurrently, it doesnt stop until i exit the multiplayer mode. I have no issues in single player mode.
    Any clue on why is that happening ?
    thank you
    Chad

    I have a question does CoD4 still have a good amount of players and does it only support mac to mac?

  • Experiencing Excessive Dropped Calls - Voicemail Delays - iPhone Freezing

    I've been having problems with excessive dropped calls (on speaker, headset, handset).
    Any conversations today (Sat 6/15) longer than a few (2-5) minutes have been dropped!!!!
    I have had two (2) very important calls today that I have had to attempt between 9-16 times due to this...
    Also... I received a missed call at exactly 6:32pm but did not get the message until 7:02pm...
    WHAT IS GOING ON????

    Have you done a reset (hold sleep/wake button and home button until the Apple logo appears)? Or a restore?
    If neither of these ideas correct the problem, you will need to make an appointment at the Genius Bar - http://apple.com/retail

  • Iphone running super slow all of a sudden and also during a call phone is freezing with a black screen and i am unable to disconnect

    My iphone 3 has just started running super slow all of the time. Also about the same time while on a call my screen is freezing black and I am unable to hang up with the caller. It is driving me crazy!!!!

    try hard reset ( hold the sleep and home button together for a few second the iphone will restart and then the an apple logo will appear)
    if this didn't work try to restore you iphone and check if there are any updates available

  • App freezes when JComboBox.addItem is called for the first time

    I have a Swing app that intermittenly freezes when the users go
    to a certain screen. I've tracked it down to a specific line. There is
    a JComboBox on the screen. The application freezes when the
    app tries to load the first item into the JComboBox using
    myComboBx.addItem(Object o). I pass in an Integer.
    The strange thing is that this only happens once a day, or
    sometimes less, in a group of 4 users. But when it does
    freeze, it always freezes on that line. After freezing, the user
    can go back into the app, and go to the same screen(no
    data has changed), and they can get in without it freezing.
    So it seems to have nothing to do with the data - it's purely
    intermittent.
    The only thing I can think of is that the underlying native peer
    for the JPanel that the JComboBox is on, has not been created
    yet, and I'm trying to load an item into a combo box that doesn't
    really exist yet. Anyone know if this is possible? It may only
    happen when the user's machine is running very slow.
    I've included the relevant code below. Any feedback would
    be greatly appreciated.
    Most of the action happens in the class ICS_COMP_PANEL.
    First, in a different class, an object of type ICS_COMP_PANEL
    is created, and then the method startCompensationScreen is
    called on that object. From then on, methods of
    ICS_COMP_PANEL are called. The app freezes on the
    COMP_NAME.addItem(retObj) call in the method
    addCompensationRecordsToScreen.
    In another class:
    screenComp = new ICS_COMP_PANEL(this);
    screenComp.startCompensationScreen();
    public class ICS_COMP_PANEL extends javax.swing.JPanel
    implements java.awt.event.ActionListener
         , java.awt.event.ItemListener
    //this is the comboBox that's causing the problem
    javax.swing.JComboBox COMP_NAME = new javax.swing.JComboBox();
    public ICS_COMP_PANEL(ICS_FOLDER iFrame)
    COMP_NAME.setEditable(true);
    jpanel1.add(COMP_NAME);
    COMP_NAME.setBackground(new java.awt.Color(204,204,204));
    COMP_NAME.setFont(new Font("Dialog", Font.BOLD, 12));
    COMP_NAME.setBounds(357,7,156,15);
    public void startCompensationScreen()throws GException
    //The line below always gets a non-empty hashtable back
    //from getCompensationRecords().
    Hashtable compList = getCompensationRecords();
    COMP_NAME.removeItemListener(this);
    addCompensationRecordsToScreen(compList);
    COMP_NAME.setSelectedIndex(0);
    loadCompensationRecord((Integer)COMP_NAME.getSelectedItem());
    COMP_NAME.addItemListener(this);
    //the only thing to notice in this function is that it loads a hashtable
    //with Integers as the keys and as elements
    private Hashtable getCompensationRecords()
    Hashtable compList = new Hashtable();
    try{
    String SQLStatement = "select comp_tran_number from comp_tran_record where
    comp_ic_tran_number = " + FOLDER.caseNumber;
    gifts.database.ResultSetCopy rsc =
    gifts.global.standardData.ICSServer.resultSetCopier(SQLStatement);
    while ( rsc.next())
    Integer compNum = rsc.getInt(1);
    compList.put(compNum,compNum);
    catch ( Exception ex){
    GTool.errorMsg(this,ex);
    return compList;
    private void addCompensationRecordsToScreen(Hashtable compList)
    System.out.println("add compensaion:");
    Enumeration e = compList.elements();
    COMP_NAME.removeAllItems();
    while ( e.hasMoreElements())
    Object retObj = e.nextElement();
    if ( retObj instanceof Integer)
    //The next line is where the app freezes
    COMP_NAME.addItem(retObj);
    //This should not get called because the itemListener is removed
    //before the JComboBox is filled.
    public void itemStateChanged(ItemEvent e)
    // This method is derived from interface java.awt.event.ItemListener
    // to do: code goes here
    System.out.println("change Item");
    Object object = e.getSource();
    if (object == COMP_NAME)
    Object retObj = COMP_NAME.getSelectedItem();
    if ( retObj instanceof Integer && COMP_NAME.getSelectedItem() !=
    currentCompensationRecord)
    reloadCompensationRecord((Integer)retObj);
    Thanks,
    Greg Sheridan
    GIFTS Software Inc.
    New York, NY

    I am facing a similar problem with JComboBox. It is responding to the first time when items are added to the combo box. Later on, listener does not seem to listen if items are added to the combo box. Can anyone think of a solutiuon for this problem. (it works fine in 1.3 but does not respond in 1.4)

  • Freezing when calling

    Hey my skype is freezing everytime I call and sometimes as it loads, I have had this issue prior to release of 7.0 and have tried older versions listed aswell as the beta that seemed to have help people with my problem.   Also using Reg cleaners and what not between installs (Eusing reg cleaner)  I appear to have a error in my event log for DHCP eveytime my computer freezes.  I can still hear my call when my computer freezes for a short time.

    Hey my skype is freezing everytime I call and sometimes as it loads, I have had this issue prior to release of 7.0 and have tried older versions listed aswell as the beta that seemed to have help people with my problem.   Also using Reg cleaners and what not between installs (Eusing reg cleaner)  I appear to have a error in my event log for DHCP eveytime my computer freezes.  I can still hear my call when my computer freezes for a short time.

  • Installing app via xcode to iphone 4s, cause iphone to freeze while calling or receiving

    i have bought recently an iphone 4s.
    i use it for development.
    everything seemed fine, install my app, test, all ok.
    BUT, if i shut down the phone, and restart it, i can't call:
    1) the screen seems calling but i can't hear the ring, the call however arrives and if someone answer doesn' hear anything, and i can't hear anything too
    2) if i click on terminate call, the screen remain freezed (button red becames grayed but nothing happens)
    3) if i send message, the message remain blocked at 90%, the message arrives, but hte phone says impossible to send
    4) if someone send me message, it doesnt arrive
    5) if someone call me, i not hear sound and nothing visible happens on iphone, but who call me says the line is free
    tyied with:
    1) change sim card
    2) repetly shutdown and restart
    3) call callcenter
    4) change the phone!!!!!!!
    the only thing i can do is restoration with itunes.......
    do someone has an idea?

    Hello, it seems that it really is not something i'm installation to make this defect:
    is happening to me again, this time I have not even installed anything but to sync the address book.
    it is possible to happen when I turn off the PC while the phone is stuck with itunes running?

  • Problems with iPhone freezing when trying to answer while on another call?

    I am wondering if others are having the problem with your iPhone freezing when you are on a call and another calls comes in. I have had this problem repeatedly. If I try to answer a call while on another call, the other caller can not hear me. when I try and hang up the call...iPhone freezes and disconnects ALL calls.
    I do not have a problem if I initiate BOTH calls for a conference call. I am hoping that Apple is aware of this issue and are working on a fix in the next update. Whenever that will be???
    Oh well, if you are having this problem and know how to fix it...please let me know. Thanks

    I have noticed that during or at the end of a conference call when one party hangs up all parties have always been disconnected. I can tell you that if this is the way it works normally, this is not the way is should work. This is a pain in the butt when it is necessary to call one of the parties back since that party is also trying to call you back. You both get a busy signal.
    I do not have a problem answering a second call during a time when I am on a first call. It will place the first call on hold and I will only be talking to the second party. It should work that way. My iPhone works that way.
    It should also allow you to add the second call to the first call through the 'merge' feature so that both the first and second calls can be joined together. My iPhone works that way.
    My previous Treo worked great on these situations but I do have burps with the iPhone.
    I think that the problem is with the iPhone and AT&T interface in these conditions.
    I would provide your comments to Apple via:
    http://www.apple.com/feedback/iphone.html.

  • Why does Face Time keep disconnecting during calls. Screen freezes up., why does Face Time keep disconnecting during calls. Screen freezes up.

    Why does Face Time keep disconnecting during calls?  The screen freezes after just a few seconds on Face Time and disconnects.

    Close All Open Apps...  Perform a Reset... Try again...
    Reset  (No Data will be Lost)
    Press and hold the Sleep/Wake button and the Home button at the same time for at least ten seconds, until the Apple logo appears. Release the Buttons.
    http://support.apple.com/kb/ht1430
    Also... See Here  >  Troubleshooting FaceTime
    Mac  http://support.apple.com/kb/TS4185

  • Blackberry 9300 Freeze During Incoming Call

    Device: Blackberry Curve 3G 9300
    OS: 6.0 Bundle 2475 (v6.0.0.546)
    Application Storage Free Space: 43.3MB
    Carrier: Maxis Communications (Malaysia)
    My phone has been freezing up randomly during incoming calls for the last 3 weeks. Sometimes I am able to pick up the call but most times it just freezes up. During the freeze, all the buttons will not work and the phone will just keep ringing until the call has been canceled/dropped from the other end.
    There are 3 scenarios:
    1. Phone works as normal. 
    2. Incoming call comes in, phone freezes up, I pull the battery out, phone reboots and everything is fine until the next freeze. I can recieve SMS and all application works as normal.
    3. Incoming call comes in, phone freezes up, I do nothing and let the call end. Screen will black out after a few seconds and none of the button works. Next incoming call comes in, the screen lights up to show the incoming call but none of the button works just like before. In the end, I have to pull out the battery.
    Here are some of the things I have tried:
    1. Deleting applications from my phone to free up memory (Facebook, Yahoo Messenger, Google Messenger)
    2. Deleting pictures to free up memory
    3. Updating the phone to the latest software version. Previously it was on version 5 but the freeze happened then too.
    4. Reseting my phone to use the original theme.
    I have never dropped my phone (not even once) and I have been using this same phone for the last 10 months. I still have 2 months left before my warranty expires. I really look forward to getting help from the experts here before I take the last option of bringing my phone to the service center.

    Basics from the manual are restart, reset, restore from backup, restore as new.

  • Freeze screen after phone calls end, upgrade problem

    Upgraded my 3Gs iphone to the last version software last week. Started to eperience problems with phone calls after the upgrade. A major problem is When incoming phone calls end, the screen freezes and does not let me do anything even cannot turn the phone off. anybody has a soloution?

    I too am experiencing this problem. It's only been a few days now, ever since I upgraded the OS and installed the latest version of iTunes last week.
    I don't know what the problem is, but I'm sick of it.
    Whenever I MAKE or RECEIVE a call, my screen freezes up and I can't do anything, not even a hard reboot.
    I dropped out of a call to someone and when they rang back I couldn't answer it. So very frustrating.
    As I write this I've just taken a call from my husband, hung up the call, and now the phone is as useful as a paperweight because I can't get any function to work on it, not even the hard reboot.
    If anyone from Apple is listening...What the **** is going on here?????

  • Computer freezes when watching videos (or video calls) since I bought a new router linksys E1200

    Hello!
    Since I've bought a new Cisco router last summer,, a Linksys E1200 (v.1 updated...) (always in the wireless mode), my laptop (Sony, Vaio VGN-NW110D) freezes when I stream videos online or when I use skype video calls. It sometimes freezes for a few minutes (in that case it's just really extremely slow and it sounds like a satanic robot), and then comes back (but does it again a few minutes later. Or sometimes, and this is more frequent with skype video calls, it completely freezes, and I have to reboot the hard way...
    This never happened to me before and I've been watching videos and video skyping for years. I have windows 7, service pack 1 (32 bits) now . I have windows 7 now, since about the same time I bought the router. But what makes me think its related to the router is that when I'm at work, or at my parents, or sisters, or boyfriend's house, this problem does NOT occure.... Do you think you could help me? This is getting really annoying! I would really appreciate it! :-) Thanks a lot! 
    ps-Oh and I don't know if this information could be relevant, but this does not happen when I make videos calls with skype on my iphone

    You can try the following combination of settings:-
    A] With the help of Cisco Connect Software (if at all you have installed the router with the help of this software)
              1] Open the software and go to the option which says "Router Settings"
              2] Then click on the option which says "Advanced Settings" which will take you to the router's configuration page.
             3] Lower the MTU (Maximum Transmission Unit) from 1500 to 1400 or less (usually found on your routers main/ basic setup page). Here is the link for determining and setting up the correct MTU size: http://www6.nohold.net/Cisco2/ukp.aspx?vw=1&docid=fbf8e8564632422eaa8ea80bf9dcba64_386.xml&pid=80&re...
    B] If you haven't installed Cisco Connect then you can log on to the router's user interface using it's default IP address in the browser which is 192.168.1.1 and type in 'admin' as the password leaving the user name field blank. This will take you to the router's web interface and then follow steps as mentioned above to make the changes.

Maybe you are looking for

  • Application works in jdeveloper but not as standalone jar file

    Hi All We have developed an application using BI Publisher APIs,it works as expected through JDevelper,however when I try to deploy it to a jar file a run it through command line it gives me No class found exception for javax/xml/rpc/Service class fa

  • Selecting open items in F-03 using additional selections

    I need to select open items in a GL account using more than one additional selection eg. document type, posting date, assignment I select Additional Selections then document type then add a document type, then I select Other Selection - posting date

  • Where can i buy a new battery?

    My battery bl-5f for my nokia nav 6210 now have a very little time of autonomy before it need a new charge.Only 1 day and the phone goes off.This means that my battery is dead?I need a new one?How much cost in italy and where can i buy it?

  • Problem regarding BAPI call from a webdynpro applications

    Hi,   We are trying to call a BAPI in R/3 system from a webdynpro application through the standard method. But we are getting some problems in JCO settings. We already wasted so much time in solving those problems. Is there anyway where i can access

  • Iphone wifi issue.

    Hi, I have an iphone 3gs white 32 gb bought in india. I have issues with the wifi. the phone is able to connect to wifi but if locked for 2 minutes,it loses the cellular network as well as wifi and finds it again. Then the wifi is unable to locate th