Package fmg.fmg8.gif

Source Code of fmg.fmg8.gif.DirectGif89Frame

//******************************************************************************
// DirectGif89Frame.java
//******************************************************************************
package fmg.fmg8.gif;

import java.awt.Image;
import java.awt.image.PixelGrabber;
import java.io.IOException;

/**
* @author Internet
*/
public class DirectGif89Frame extends AbstractGif89Frame {

    /**
     * Comment.
     */
    private int[] argbPixels;

    /**
     * Construct an DirectGif89Frame from a Java image.
     *
     * @param img
     *            A java.awt.Image object that supports pixel-grabbing.
     * @exception IOException
     *                If the image is unencodable due to failure of
     *                pixel-grabbing.
     */
    public DirectGif89Frame(final Image img) throws IOException {
        PixelGrabber pg = new PixelGrabber(img, 0, 0, -1, -1, true);

        String errmsg = null;
        try {
            if (!pg.grabPixels()) {
                errmsg = "can't grab pixels from image";
            }
        } catch (InterruptedException e) {
            errmsg = "interrupted grabbing pixels from image";
        }

        if (errmsg != null) {
            throw new IOException(errmsg + " (" + getClass().getName() + ")");
        }

        theWidth = pg.getWidth();
        theHeight = pg.getHeight();
        argbPixels = (int[]) pg.getPixels();
        ciPixels = new byte[argbPixels.length];
    }

    /**
     * Construct an DirectGif89Frame from ARGB pixel data.
     *
     * @param width
     *            Width of the bitmap.
     * @param height
     *            Height of the bitmap.
     * @param argbPixels2
     *            Array containing at least width*height pixels in the format
     *            returned by java.awt.Color.getRGB().
     */
    public DirectGif89Frame(
            final int width,
            final int height,
            final int[] argbPixels2) {
        theWidth = width;
        theHeight = height;
        argbPixels = new int[theWidth * theHeight];
        System.arraycopy(argbPixels2, 0, argbPixels, 0, argbPixels.length);
        ciPixels = new byte[argbPixels.length];
    }

    /**
     * @return Comment.
     */
    Object getPixelSource() {
        return argbPixels;
    }
}
TOP

Related Classes of fmg.fmg8.gif.DirectGif89Frame

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.