HI,
Chris Jackson wrote:
> The image is 142 x 146 pixels (At least that's what I'm using the look at it
> - other doc I've got sais it is 152x144).
Chris, I had worked out that the thumbnail was 141 pixels wide!
I have a very simple Java application that can decode these images (after they
have been extracted). It simply takes, as command line arguments, the
dimensions of the image and the file name.
i.e. java TMImage 141 146 tm011200.imt
I have attached both the java source and the compiled class (JDK 1.1). and
the jpeg version of the image.
-- John Melton n6lyt/g0orx
import java.awt.*;
import java.awt.image.*;
import java.io.*;
class TMImage extends Canvas {
private int width;
private int height;
private Image image;
TMImage(int width,int height,File file) {
this.width=width;
this.height=height;
image=loadImage(file);
}
public Dimension getMinimumSize() {
return getPreferredSize();
}
public Dimension getPreferredSize() {
return new Dimension(width,height);
}
public void paint(Graphics g) {
g.drawImage(image,0,0,this);
}
private Image loadImage(File file) {
Image image=null;
try {
int size=width*height;
byte[] buffer=new byte[size];
BufferedInputStream s=new BufferedInputStream(new FileInputStream(file));
int bytes=0;
while(bytes<size) {
bytes+=s.read(buffer,bytes,size-bytes);
}
int[] pixels=new int[size];
for(int i=0;i<size;i++) {
byte b=buffer[i];
pixels[i]=(255<<24)+(b<<16)+(b<<8)+b;
}
MemoryImageSource m=new MemoryImageSource(width,height,pixels,0,width);
image=Toolkit.getDefaultToolkit().createImage(m);
} catch (IOException e) {
System.out.println("loadImage: "+e.getMessage());
System.exit(0);
}
return image;
}
public static void main(String[] args) {
int width=0;
int height=0;
if(args.length!=3) {
System.out.println("usage: java TMImage width height file");
System.exit(0);
}
try {
width=Integer.parseInt(args[0]);
height=Integer.parseInt(args[1]);
} catch (NumberFormatException e) {
System.out.println("Error: width and height must be integers");
System.exit(0);
}
File file=new File(args[2]);
if(!file.exists()) {
System.out.println("Error: file not found");
System.exit(0);
}
if(file.length()<(width*height)) {
height=(int)file.length()/width;
System.out.println("Warning: short file - adjusting height to "+height);
}
Frame frame=new Frame("TMImage: "+args[2]+" ("+width+"x"+height+")");
frame.add(new TMImage(width,height,file));
frame.pack();
frame.setVisible(true);
}
}
tm011200.jpg