2003-03-26 05:39:34 +00:00
|
|
|
/*
|
|
|
|
* AppleCommander - An Apple ][ image utility.
|
2022-01-19 03:55:20 +00:00
|
|
|
* Copyright (C) 2002-2022 by Robert Greene
|
2003-03-26 05:39:34 +00:00
|
|
|
* robgreene at users.sourceforge.net
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
package com.webcodepro.applecommander.storage.filters.imagehandlers;
|
|
|
|
|
|
|
|
import java.awt.image.BufferedImage;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.OutputStream;
|
|
|
|
|
2017-06-12 17:06:21 +00:00
|
|
|
import javax.imageio.*;
|
2004-06-09 03:58:00 +00:00
|
|
|
|
2003-03-26 05:39:34 +00:00
|
|
|
/**
|
|
|
|
* SunJpegImage is a specific implementation of AppleImage that handles all
|
|
|
|
* SUN JPEG codec related coding surrounding image manipulation. This is
|
|
|
|
* available only on SUN JVMs.
|
|
|
|
* <p>
|
|
|
|
* Date Created: Mar 25, 2003
|
|
|
|
* @author Rob Greene
|
|
|
|
*/
|
|
|
|
public class SunJpegImage extends AppleImage {
|
|
|
|
private BufferedImage image;
|
|
|
|
/**
|
|
|
|
* Create SunJpegImage. Verifies all (known) required classes are available
|
|
|
|
* as well as sets up the class.
|
|
|
|
*/
|
|
|
|
public SunJpegImage(int width, int height) throws ClassNotFoundException {
|
2004-07-04 21:58:01 +00:00
|
|
|
super(new String[] { "JPEG" }); //$NON-NLS-1$
|
|
|
|
Class.forName("com.sun.image.codec.jpeg.JPEGCodec"); //$NON-NLS-1$
|
2003-03-26 05:39:34 +00:00
|
|
|
image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Set a color point.
|
|
|
|
*/
|
|
|
|
public void setPoint(int x, int y, int color) {
|
|
|
|
image.setRGB(x, y, color);
|
|
|
|
}
|
2003-12-22 01:19:39 +00:00
|
|
|
/**
|
|
|
|
* Get a color point.
|
|
|
|
*/
|
|
|
|
public int getPoint(int x, int y) {
|
|
|
|
return image.getRGB(x,y);
|
|
|
|
}
|
2003-03-26 05:39:34 +00:00
|
|
|
/**
|
|
|
|
* Save the image.
|
|
|
|
*/
|
|
|
|
public void save(OutputStream outputStream) throws IOException {
|
2017-06-12 17:06:21 +00:00
|
|
|
ImageIO.write(image, "jpg", outputStream);
|
2003-03-26 05:39:34 +00:00
|
|
|
}
|
2003-12-22 01:19:39 +00:00
|
|
|
/**
|
|
|
|
* Return the width of the image.
|
|
|
|
*/
|
|
|
|
public int getWidth() {
|
|
|
|
return image.getWidth();
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Return the height of the image.
|
|
|
|
*/
|
|
|
|
public int getHeight() {
|
|
|
|
return image.getHeight();
|
|
|
|
}
|
2003-03-26 05:39:34 +00:00
|
|
|
}
|