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 3 of 3

Thread: Movie of BufferedImages

  1. #1
    Junior Member
    Join Date
    Mar 2012
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Movie of BufferedImages

    Hi guys, I've made a little movie out of BufferedImages and it runs beautifully, however, the problem I'm faced with is loading time.
    By loading time, I mean the time it takes to craft this array list of BufferedImages.

    By the way, the movie is just an image that fades in and out.

    I have pinpointed the problem to be that whenever I create a new BufferedImage, it just takes way too much time for java to allocate that memory.

    Here is a code snipit:

    private BufferedImage setAlpha(byte alpha) {
        	BufferedImage temp = null;
            alpha %= 0xff; 
     
            try {
    	     temp = ImageIO.read(new File("images\\intro.png"));
    	} catch (IOException e) {}
     
            for (int cx=112;cx<675;cx++) {          
                for (int cy=8;cy<567;cy++) {
     
                	if(temp != null){
    	                int color = temp.getRGB(cx, cy);
    	                int mc = (alpha << 24) | 0x00ffffff;
    	                int newcolor = color & mc;
    	                temp.setRGB(cx, cy, newcolor);  
                	}
     
                }
            }        
            return temp;
        }

    temp = ImageIO.read(new File("images\\intro.png")); is the line that takes forever, does anyone have any suggestions?

    Thank you,

    Ludicrous


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,619
    Thanks
    45
    Thanked 1,958 Times in 1,932 Posts

    Default Re: Movie of BufferedImages

    Some thoughts:
    How large are the image files?
    How long does it take to read the bytes of a file?

    Can the files be read before they are shown? Can the image files be read on another thread while other images are being shown?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Mar 2012
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Movie of BufferedImages

    Hey, thanks for the reply.

    After doing research, it turns out ImageIO.read() is just dirt slow, and I might need to find some other way to doing my movie.

    Can the image files be read on another thread while other images are being shown?
    This is very true, thank you.

Similar Threads

  1. [JMF] Generate a QuickTime movie of H.263 encoding from a list of jpeg frame
    By wangminghz2 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 5th, 2013, 01:45 AM
  2. Setting individual sRGB pixel values on BufferedImages
    By nitrogenFingers in forum AWT / Java Swing
    Replies: 2
    Last Post: February 11th, 2011, 09:27 AM
  3. Trying to achieve Movie Style Rolling Credits
    By javanoob123 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 10th, 2011, 07:02 PM
  4. XOR'ing BufferedImages onto a Graphics2D object
    By nemo in forum AWT / Java Swing
    Replies: 6
    Last Post: November 14th, 2010, 02:33 PM