aspose file tools*
The moose likes I/O and Streams and the fly likes how can i display the information that is read from the .gif file- urgently Required Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Reply locked New topic
Author

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

sreelakshmi kolla
Ranch Hand

Joined: Aug 23, 2007
Posts: 35
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
Marshal

Joined: Mar 22, 2005
Posts: 42648
    
  65
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.


Ping & DNS - my free Android networking tools app
sreelakshmi kolla
Ranch Hand

Joined: Aug 23, 2007
Posts: 35
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

Joined: Oct 29, 2001
Posts: 8971
    
    9

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.


[How To Ask Questions On JavaRanch]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: how can i display the information that is read from the .gif file- urgently Required