Added getPoint, getWidth, getHeight.

This commit is contained in:
Robert Greene 2003-12-22 01:19:39 +00:00
parent ac2d621645
commit d662a42c0d
4 changed files with 66 additions and 0 deletions

View File

@ -114,8 +114,20 @@ public abstract class AppleImage {
* Set a color point.
*/
public abstract void setPoint(int x, int y, int color);
/**
* Get a color point.
*/
public abstract int getPoint(int x, int y);
/**
* Save the image.
*/
public abstract void save(OutputStream outputStream) throws IOException;
/**
* Return the width of the image.
*/
public abstract int getWidth();
/**
* Return the height of the image.
*/
public abstract int getHeight();
}

View File

@ -50,10 +50,28 @@ public class ImageIoImage extends AppleImage {
public void setPoint(int x, int y, int color) {
image.setRGB(x, y, color);
}
/**
* Get a color point.
*/
public int getPoint(int x, int y) {
return image.getRGB(x,y);
}
/**
* Save the image.
*/
public void save(OutputStream outputStream) throws IOException {
ImageIO.write(image, getFileExtension(), outputStream);
}
/**
* Return the width of the image.
*/
public int getWidth() {
return image.getWidth();
}
/**
* Return the height of the image.
*/
public int getHeight() {
return image.getHeight();
}
}

View File

@ -50,10 +50,28 @@ public class SunJpegImage extends AppleImage {
public void setPoint(int x, int y, int color) {
image.setRGB(x, y, color);
}
/**
* Get a color point.
*/
public int getPoint(int x, int y) {
return image.getRGB(x,y);
}
/**
* Save the image.
*/
public void save(OutputStream outputStream) throws IOException {
JPEGCodec.createJPEGEncoder(outputStream).encode(image);
}
/**
* Return the width of the image.
*/
public int getWidth() {
return image.getWidth();
}
/**
* Return the height of the image.
*/
public int getHeight() {
return image.getHeight();
}
}

View File

@ -58,6 +58,12 @@ public class SwtImage extends AppleImage {
public void setPoint(int x, int y, int color) {
imageData.setPixel(x, y, color);
}
/**
* Get a color point.
*/
public int getPoint(int x, int y) {
return imageData.getPixel(x,y);
}
/**
* Save the image.
*/
@ -76,4 +82,16 @@ public class SwtImage extends AppleImage {
}
imageLoader.save(outputStream, format);
}
/**
* Return the width of the image.
*/
public int getWidth() {
return imageData.width;
}
/**
* Return the height of the image.
*/
public int getHeight() {
return imageData.height;
}
}