Fala pessoal beleza ? Estou com um pequeno problema, eu preciso abrir uma imagem TIFF, colocar um numero dentro dela, numa posição x,y , e depois salva-la. Apenas isso, o problema é que, eu não consigo colocar dado nela, ou seja, uma string por exemplo. Alguem pode me ajudar? Ae vai meu codigo atual.
import java.awt.Frame;
import java.awt.image.DataBuffer;
import java.awt.image.renderable.ParameterBlock;
import java.io.IOException;
import javax.media.jai.JAI;
import javax.media.jai.LookupTableJAI;
import javax.media.jai.RenderedOp;
import com.sun.media.jai.codec.FileSeekableStream;
import com.sun.media.jai.codec.TIFFDecodeParam;
import java.io.File;
import javax.media.jai.widget.ScrollingImagePanel;
public class teste2 {
public static void main(String[] args)
{
File file = new File("C:/documents and settings/euclides/workspace/adagri/src/img1.tif");
FileSeekableStream stream = null;
try
{
stream = new FileSeekableStream(file);
} catch (IOException e)
{
e.printStackTrace();
System.exit(0);
}
ParameterBlock params = new ParameterBlock();
params.add(stream);
TIFFDecodeParam decodeParam = new TIFFDecodeParam();
decodeParam.setDecodePaletteAsShorts(true);
RenderedOp image1 = JAI.create("tiff", params, null);
int dataType = image1.getSampleModel().getDataType();
RenderedOp image2 = null;
if (dataType == DataBuffer.TYPE_BYTE)
{
System.out.println("TIFF image is type byte.");
image2 = image1;
} else
{
System.out.println("TIFF image is type " + dataType +
", and will not be displayed.");
System.exit(0);
}
int width = image2.getWidth();
int height = image2.getHeight();
ScrollingImagePanel panel = new ScrollingImagePanel(image2, width, height);
Frame window = new Frame("ImagemTIFF");
window.add(panel);
window.pack();
window.show();
}
}
