Results 1 to 2 of 2
  1. #1
    xperia2995 is offline Member
    Join Date
    Dec 2012
    Posts
    4
    Rep Power
    0

    Default Strange Image IO ?

    I am testing the code for a 4X4 gif image named abc which I made with MSpaint which contained 2 black pixels and rest as white
    Once I ran the code the output was
    -1 -1 -1 -1
    -1 -1 -16777216 -1
    -1 -1 -1 -1
    -16777216 -1 -1 -1

    I compiled and ran the same program again now output is

    -1 -1 -1 -16777216
    -1 -1 -1 -16777216
    -1 -1 -1 -16777216
    -16777216 -1 -1 -16777216

    Isn't this strange because my program reads and doesn't modify any pixel data?

    After the first run the image is unmodified in MS Paint also
    but after the second run the modification is visible in MS Paint also

    How can I prevent this from happening?
    Is something wrong with my output code?

    CODE
    public static void main(String args[])throws Exception
    {
    BufferedImage img;
    File ptr =new File("abc.gif");
    img = ImageIO.read(ptr);

    int height=img.getHeight();
    int width=img.getWidth();

    int rgb;

    for(int i=0;i<width;i++)
    {
    for(int j=0;j<height;j++)
    {
    rgb =img.getRGB(i,j);
    System.out.print(rgb+" ");
    }
    System.out.print("\n");
    }

    ImageIO.write(img,"gif",ptr);
    }

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: Strange Image IO ?

    You didn't return to the last two threads you started and you didn't heed my advice to go through certain links which I posted in your first thread, which was locked. Why should we expect you to return to this thread?

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

Similar Threads

  1. Java Applet Strange Image Loading Problem
    By 1yuchen in forum Java Applets
    Replies: 36
    Last Post: 01-06-2012, 02:06 AM
  2. Strange for loop
    By Grimmjow in forum New To Java
    Replies: 5
    Last Post: 01-23-2011, 10:52 PM
  3. Strange JVM behaviour
    By pjpr in forum Advanced Java
    Replies: 13
    Last Post: 01-03-2011, 07:39 PM
  4. strange swt exception
    By ahmed.kotb in forum SWT / JFace
    Replies: 0
    Last Post: 04-23-2009, 10:15 AM
  5. Replies: 0
    Last Post: 01-08-2008, 05:29 PM

Posting Permissions

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