📄 magickimage.java
字号:
package magick;import java.awt.Dimension;import java.awt.Rectangle;/** * Encapsulation of the ImageMagick Image object. * We use MagickImage here so as not to be confused * with java.awt.Image. * * @author Eric Yeo */public class MagickImage extends Magick { /** * Internal ImageMagick Image handle. * We use long (64-bits) for portability. */ private long magickImageHandle = 0; /** * Constructor. */ public MagickImage() { } /** * Construct a MagickImage that is made up of all * the images in the specified array. If any of * the images contains multiple frames, the frames * are also appended to the new image. All the * images are cloned. * @param images array of images to linked */ public MagickImage(MagickImage[] images) throws MagickException { initMultiImage(images); } /** * Helper for the constcutor to create an image that * is made up of all the images in the specified array. * If any of the images contains multiple frames, the * frames are also appended to the new image. All the * images are cloned. * @param images array of images to linked * @throws MagickException if the new image cannot be constructed * @see MagickImage */ private native void initMultiImage(MagickImage[] images) throws MagickException; /** * Constructor that also reads an image file * specified in the parameter. * * @param imageInfo the ImageInfo for an image file to read * @param boolean true for ping the image only. * * @exception MagickException on error */ public MagickImage(ImageInfo imageInfo, boolean ping) throws MagickException { if (ping) { pingImage(imageInfo); } else { readImage(imageInfo); } } /** * Pings the image. * @param imageInfo the ImageInfo for an image file to read */ public native void pingImage(ImageInfo imageInfo) throws MagickException; /** * Constructor that also reads an image file * specified in the parameter. * * @param imageInfo the ImageInfo for an image file to read * * @exception MagickException on error on error */ public MagickImage(ImageInfo imageInfo) throws MagickException { readImage(imageInfo); } /** * Constructor that takes the image to be read from memory. * * @param imageInfo the ImageInfo instance for default settings, etc * @param blob the image to be read in memory * * @exception MagickException on error */ public MagickImage(ImageInfo imageInfo, byte[] blob) throws MagickException { blobToImage(imageInfo, blob); } /** * This method will clean up the handle. */ protected void finalize() { destroyImages(); } /** * Allocate a blank image object. * * @param imageInfo specifies the parameters for the blank image */ public native void allocateImage(ImageInfo imageInfo); /** * Read the image specified in the ImageInfo object. * * @param imageInfo specifies the file to read from * @exception MagickException on error */ public native void readImage(ImageInfo imageInfo) throws MagickException; /** * Write the image specified in the ImageInfo object. * * @param imageInfo specifies the writing parameters * * @exception MagickException on error */ public native boolean writeImage(ImageInfo imageInfo) throws MagickException; /** * Return the image file name of the image. * * @return the file name of the image * @exception MagickException on error */ public native String getFileName() throws MagickException; /* * Set the image file name. * * @param fileName new file name * * @exception MagickException on error */ public native void setFileName(String fileName) throws MagickException; /* * Set the filter type. * * @param the filter type from constants defined in the class FilterType * @see FilterType * @exception MagickException on error */ public native void setFilter(int filter) throws MagickException; /* * Get the filter type. * * @return the filter type as defined in the class FilterType * @see FilterType * @exception MagickException on error */ public native int getFilter() throws MagickException; /* * Return the number of columns and rows of the image. * @return the dimension of the image * @exception MagickException on error */ /** * Adds random noise to the image. * * @param noiseType The type of noise: Uniform, Gaussian, Multiplicative, * Impulse, Laplacian, or Poisson. * @see NoiseType * @return An image with additional noise. * @exception MagickException on error */ public native MagickImage addNoiseImage(int noiseType) throws MagickException; public native Dimension getDimension() throws MagickException; /** * Return the depth of the image. * * @return the depth of the image. * @exception MagickException on error */ public native int getDepth() throws MagickException; /** * Blurs an image. We convolve the image with a Gaussian operator of * the given radius and standard deviation (sigma). For reasonable * results, the radius should be larger than sigma. Use a radius of 0 * and BlurImage() selects a suitable radius for you. * * @param raduis The radius of the gaussian, in pixels, not counting * the center pixel * @param sigma The standard deviation of the gaussian, in pixels * * @return A blurred image. * @exception MagickException on error */ public native MagickImage blurImage(double raduis, double sigma) throws MagickException; /** * Return the storage class of the image. * * @return the store class as defined in ClassType * @see ClassType * @exception MagickException on error */ public native int getStorageClass() throws MagickException; /* * Annotates an image with test. Optionally the annotation can * include the image filename, type, width, height, or scene * number by embedding special format characters. * * @param info the anotation information */ public native void annotateImage(DrawInfo info); /** * Surrounds the image with a border of the color defined by * the border color member of the image structure. The width * and height of the border are defined by the corresponding * members of the Rectangle. * * @param borderInfo the rectangle for which border is drawn * @return an Image with a border around it * @exception MagickException on error * @see #setBorderColor * @see #getBorderColor */ public native MagickImage borderImage(Rectangle borderInfo) throws MagickException; /** * Creates a new image that is a copy of an existing one with the * edges highlighted, producing a 'charcoal-drawing' effect. * * @param raduis The radius of the pixel neighborhood. * @param sigma The standard deviation of the gaussian, in pixels * * @return A charcoal-like image. * @exception MagickException on error */ public native MagickImage charcoalImage(double raduis, double sigma) throws MagickException; /** * Creates a simulated three-dimensional button-like effect by * lightening and darkening the edges of the image. Members width * and height of raiseInfo define the width of the vertical and * horizontal edge of the effect. * * @param raiseInfo the rectangle for which border is drawn * @param raise true to create raise effect, false to lower * @return true if successful, false otherwise * @exception MagickException on error */ public native boolean raiseImage(Rectangle raiseInfo, boolean raise) throws MagickException; /** * Creates a new image that is a subregion of the original. * * @param chopInfo the rectange to chop the image * @exception MagickException on error */ public native MagickImage chopImage(Rectangle chopInfo) throws MagickException; /** * Colourises the image with a pen colour. * * @param opacity string percentage value for opacity * @param target a colour value * @exception MagickException on error */ public native MagickImage colorizeImage(String opacity, PixelPacket target) throws MagickException; /** * Composite the image supplied onto itself at the specified offsets. * @exception MagickException on error */ public native boolean compositeImage(int compOp, MagickImage compImage, int xOff, int yOff) throws MagickException; /** * Enhances the intensity differences between the lighter and * darker elements of the image. * @return a boolean value to indicate success * @exception MagickException on error */ public native boolean contrastImage(boolean sharpen) throws MagickException; /** * Returns a copy of all fields of the input image. * The the pixel memory is allocated but the pixel data is copy * is optional. * @return a cloned image * @exception MagickException on error */ public native MagickImage cloneImage(int columns, int rows, boolean clonePixels) throws MagickException; /** * Create a new image of 8-bit component of the specified dimensions. * * @param width the width of the new image * @param height the height of the new image * @param map the components of a pixel * @param pixels the raw image in an array of pixels * @exception MagickException on error */ public native void constituteImage(int width, int height, String map, byte[] pixels) throws MagickException; /** * Create a new image of 32-bit component of the specified dimensions. * * @param width the width of the new image * @param height the height of the new image * @param map the components of a pixel * @param pixels the raw image in an array of pixels * @exception MagickException on error */ public native void constituteImage(int width, int height, String map, int[] pixels) throws MagickException; /** * Create a new image of float component of the specified dimensions. * * @param width the width of the new image * @param height the height of the new image * @param map the components of a pixel * @param pixels the raw image in an array of pixels * @exception MagickException on error */ public native void constituteImage(int width, int height, String map, float[] pixels) throws MagickException; /** * Creates a new image that is a subregion of the original. * * @param chopInfo the subimage * @return a subimage of the original * @exception MagickException on error */ public native MagickImage cropImage(Rectangle chopInfo) throws MagickException; /** * Cycles the image colormap by a specified amount. * @exception MagickException on error */ public native void cycleColormapImage(int amount) throws MagickException; /** * Called by finalize to deallocate the image handle. */ public native void destroyImages();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -