Java - Guardar en Fichero, Datos de una Imagen

 
Vista:

Guardar en Fichero, Datos de una Imagen

Publicado por lilu (112 intervenciones) el 22/05/2006 19:10:27
Buenos días a todos desde Maracaibo...

Tengo dos problemas por aca, voy al grano, tengo este programita:

import java.awt.*;
import java.applet.*;
import java.awt.image.*;

public class ConvolveIt extends Applet {

BufferedImage bi;

public void init() {
Image img = getImage(getClass().getResource("jaeger.jpg"));//19
try {
MediaTracker tracker = new MediaTracker(this);
tracker.addImage(img, 0);
tracker.waitForID(0);
} catch (Exception e) {
}
bi = new BufferedImage (img.getWidth(this), img.getHeight(this), BufferedImage.TYPE_INT_RGB);
Graphics2D big = bi.createGraphics();//27
big.drawImage(img, 0, 0, this);
}

public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D)g;
if (bi != null) {//33
g2d.drawImage(bi, 10, 10, this);
}
}

public boolean mouseMove(Event e, int x, int y)
{
int r, g, b;
ColorModel color;

color = bi.getColorModel();
r = color.getRed(bi.getRGB(x,y));
g = color.getGreen(bi.getRGB(x,y));
b = color.getBlue(bi.getRGB(x,y));
showStatus("x = "+x+" y = "+y+" Red = "+r+" Green = "+g+" Blue = "+b);//47
return true;
}
}

Al compilarlo me sale esta NOTA.
Note: C:\Archivos de programa\Xinox Software\JCreatorV3\MyProjects\ConvolveIt\src\ConvolveIt.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

Process completed.

Ahora cuando lo ejecuto me sale esta Exception:

java.lang.NullPointerException
at sun.awt.image.URLImageSource.<init>(URLImageSource.java:27)
at sun.applet.AppletImageRef.reconstitute(AppletImageRef.java:33)
at sun.misc.Ref.get(Ref.java:47)
at sun.applet.AppletViewer.getCachedImage(AppletViewer.java:377)
at sun.applet.AppletViewer.getImage(AppletViewer.java:372)
at java.applet.Applet.getImage(Applet.java:236)
at ConvolveIt.init(ConvolveIt.java:19)
at sun.applet.AppletPanel.run(AppletPanel.java:378)
at java.lang.Thread.run(Thread.java:595)

Necesito saber el porque de esta Exception.

Además de ello necesito que por favor me digan como haría yo para guardar esas variables en un archivo, es decir, guardar r, g, b en un archivo o fichero.

r = color.getRed(bi.getRGB(x,y));
g = color.getGreen(bi.getRGB(x,y));
b = color.getBlue(bi.getRGB(x,y));
FileOutputStream?.. algo asi, acompañado claro con un bucle?.

Es que necesito guardar los datos o la informacion de una imagen o textura en un archivo o fichero para asi poder trabajar con él.

Gracias de antemano?
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder