Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
    Bookmark Topic Watch Topic
  • New Topic

how can i display the information that is read from the .gif file- urgently Required

 
sreelakshmi kolla
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Report post to moderator
HI EVERYONE,

here is my code:

import java.awt.image.*;
import java.awt.*;
import java.awt.Toolkit;
import java.io.*;


public class ReadGif{
public static void main(String args[])throws Exception{


PixelGrabber pg;
Image mapI;
Image nowI;
int[] mapx = new int[300*500];

mapI = Toolkit.getDefaultToolkit().createImage("D:/Myapps/read/4843a349.gif"); // load the image

pg = new PixelGrabber(mapI,0,0,500,300,mapx,0,500);
try
{
boolean b=pg.grabPixels();
int h=pg.getHeight();
int w=pg.getWidth();
int s=pg.getStatus();
System.out.println("the height of the image is"+s);

System.out.println("is successfully collected"+b);
}
catch (InterruptedException e) {}


//
// manipulate the pixels
//





}
}

here i used PixelGrabber class,but there is no method in that class to read exctly the content in gif file? can anyone suggest the class to read?i tried it out by using so many classes.but didn't get the correct one!

Regards,
sreelakshmi
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Report post to moderator
If you want the pixel values, it's easier to use the javax.imageio.ImageIO.read method. That returns a BufferedImage, from which you can obtain a Raster, which contains the pixel data.
 
sreelakshmi kolla
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi Ulf Dittmer ,

i have tried it out in that way.here is my code:

import java.awt.*;
import java.io.*;
import java.awt.event.*;
import java.awt.image.*;
import java.awt.geom.*;
import java.awt.font.*;

import javax.swing.*;
import javax.imageio.*;


public class ReadGGif{

public static void main(String s[]) throws Exception {
File f=new File("D:/Myapps/read/4843a349.gif");
BufferedImage bufferedImage=ImageIO.read(f);
Raster raster = bufferedImage.getData();
DataBuffer dbuffer = raster.getDataBuffer();
int size = dbuffer.getSize();
System.out.println("Size of the File:"+size);

System.out.println("Data Type:"+dbuffer.getDataType());

System.out.println("Get Element:"+dbuffer.getElem(0, 0));
}


}


but my intention is put that data that is read from the .gif file into .doc file!
can you tell me what can i do inorder to achieve that??--it is some what urgent!!

Regards,
sreelakshmi.
 
Joe Ess
Bartender
Pie
Posts: 9258
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Report post to moderator
Originally posted by sreelakshmi kolla:

but my intention is put that data that is read from the .gif file into .doc file!
can you tell me what can i do inorder to achieve that??--it is some what urgent!!


You can't do that, as myself and Peter told you in your other post. Again, I'm going to ask you to read our FAQ, especially Ease Up and Use One Thread Per Question.
 
    Bookmark Topic Watch Topic
  • New Topic