Results 1 to 4 of 4
  1. #1
    jdawg18 is offline Member
    Join Date
    Oct 2014
    Posts
    1
    Rep Power
    0

    Default Buffered Image COORDINATES OUT OF BOUNDS error

    Hi everyone,
    I'm pretty new to Java, but not new to programming. However, I'm still having an issue with this picture program...

    I am writing a java program that takes a FROM image, a TO image, and a ratio (this is a slide bar in the GUI). Here's my code:
    Java Code:
    public static BufferedImage rollUp (BufferedImage from, 
    BufferedImage to, 
    double ratio) { 
    
    BufferedImage finalBufferedImage = new BufferedImage(from.getWidth(), 
    from.getHeight(), 
    from.getType()); 
    int packedColor = 0; 
    for (int r = 0; r < from.getHeight(); ++r) { 
    for (int c = 0; c < from.getWidth() ; ++c) { 
    
    if(r < from.getHeight() * (1-ratio)){ 
    packedColor = from.getRGB(c, (int) ((from.getHeight() * ratio)+r)); 
    }else{ 
    packedColor = to.getRGB(c, (int) (r-from.getHeight() * (1-ratio))); 
    } 
    
    finalBufferedImage.setRGB(c, r, packedColor); 
    } 
    }	
    return finalBufferedImage; 
    }
    So from 0 to 1 (ratio is a double between 0 and 1) the image will "roll up". The effect works completely in the GUI, but the console freaks out at about 0.33 ratio.. This program runs for testing in a class Main and uses a class Splittinimage.. this method is in class TwixPix. When the main class is run, a box pops up with a combo box and a slider. You pick an effect (in this case, roll up) and then slide the slider to set the ratio. The image below those two things performs the effect that was selected. Imagine a PowerPoint presentation slide effect. Can someone tell me why this is happening?

    Thanks! I really appreciate it.
    Last edited by jdawg18; 10-31-2014 at 12:50 AM.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,001
    Rep Power
    33

    Default Re: Buffered Image COORDINATES OUT OF BOUNDS error

    Please edit your post and wrap your code with highlight tags:
    [code]
    YOUR CODE GOES HERE
    [/code]
    to get highlighting and preserve formatting.

    How can the code be compiled and executed for testing?
    Last edited by Norm; 10-31-2014 at 12:28 AM.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    25

    Default Re: Buffered Image COORDINATES OUT OF BOUNDS error

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Buffered Image COORDINATES OUT OF BOUNDS error

    Would you please include the driver program used for testing? A Short, Self Contained, Correct Example would be appropriate here.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. Coordinates out of bounds
    By trishtren in forum Java 2D
    Replies: 3
    Last Post: 05-19-2011, 08:10 PM
  2. Buffered Image and DataBuffer
    By ErdyMurphy in forum Java 2D
    Replies: 1
    Last Post: 04-19-2011, 04:55 AM
  3. Volatile image vs buffered image
    By trishtren in forum Java 2D
    Replies: 0
    Last Post: 04-17-2011, 11:31 PM
  4. Drawing onto a buffered image
    By trishtren in forum Java 2D
    Replies: 3
    Last Post: 04-09-2011, 09:23 PM
  5. Rotating Buffered Image distorts image
    By VortexSpin in forum Java 2D
    Replies: 1
    Last Post: 02-13-2011, 05:54 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •