Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Incremental image drawing in Java

  1. #1
    Junior Member
    Join Date
    Apr 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Incremental image drawing in Java

    Hi all,

    My first post on these boards so greetings to all. I have the following applet which is supposed to fetch a big image via url and render it on an applet using drawImage. I want my applet to render the image in an incremental fashion as the image is loaded (which is supposed to be the defualt manner by which drawImage works). I also learned that there must be a System Property awt.image.drawIncremental which should be set to true so that incremental drawing can be enabled (I had to set it manually as it was defaulted to false)

    However the image is still being rendered when all image bytes are loaded from the URL. Here is my code:

    import java.applet.*;
    import java.awt.*;
    import java.awt.image.ImageObserver;
    import java.io.IOException;
    import java.net.URL;
     
    public class imageApp extends Applet {
        Image image;
     
        public void init () {
        	System.setProperty("awt.image.incrementalDraw", "true"); 
        	incrementaldraw = Boolean.getBoolean("awt.image.incrementalDraw");
            System.out.println(incrementaldraw); //Verify incrementalDraw is set to true
     
        	try{
    			URL url = new URL("http://geoeyemediaportal.s3.amazonaws.com/gallery/Inauguration_2009.jpg");
    			image = getImage(url);
    	}
    	catch(IOException e){}
        }
        public void paint (Graphics g) {
                g.drawImage (image, 0, 0, this);
        }
        public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height) {
                if ((infoflags & SOMEBITS ) != 0){
                    repaint();
                }
                return super.imageUpdate(img, infoflags, x, y, width, height);
        }
    }

    I would greatly appreciate some help from you guys as I am at a loss. Thanks everyone


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,610
    My Mood
    Hungover
    Thanks
    145
    Thanked 658 Times in 563 Posts

    Default Re: Incremental image drawing in Java

    I don't begrudge you too much because we couldn't really find a solution on the other forum, but you should have still told us about the other post.

    This thread has been cross posted here:

    http://www.java-forums.org/new-java/42337-java-applet-loading-image-render-you-get-image.html

    Although cross posting is allowed, for everyone's benefit, please read:

    Java Programming Forums Cross Posting Rules

    The Problems With Cross Posting

    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Apr 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Incremental image drawing in Java

    Sorry for my negligence to include a link for my cross-post

  4. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,610
    My Mood
    Hungover
    Thanks
    145
    Thanked 658 Times in 563 Posts

    Default Re: Incremental image drawing in Java

    Quote Originally Posted by ea25 View Post
    Sorry for my negligence to include a link for my cross-post
    No big deal. This is one of the few cases where crossposting was valid. It's just helpful for people to see what has already been discussed in the original post, otherwise they might waste their time repeating advice you've already tried.

    Hopefully somebody here will be able to make heads or tails of this.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Replies: 2
    Last Post: February 14th, 2011, 05:36 PM
  2. Openning Image with java
    By shadihrr in forum Java Theory & Questions
    Replies: 3
    Last Post: February 3rd, 2010, 06:44 AM
  3. Incremental Build
    By ashwin in forum Java IDEs
    Replies: 0
    Last Post: January 12th, 2010, 06:21 AM
  4. Drawing image on JPanel from another frame
    By jeryslo in forum AWT / Java Swing
    Replies: 3
    Last Post: December 8th, 2009, 04:01 PM
  5. Pixel Alteration in an image/image rotation
    By bguy in forum Java Theory & Questions
    Replies: 3
    Last Post: November 1st, 2009, 10:50 AM