/*
 * Java-Gnome Bindings Library
 *
 * Copyright 1998-2005 the Java-Gnome Team, all rights reserved.
 *
 * The Java-Gnome bindings library is free software distributed under
 * the terms of the GNU Library General Public License version 2.
 */

package org.freedesktop.cairo;

import org.gnu.glib.Handle;

/**
 *
 * @deprecated This class is part of the java-gnome 2.x family of libraries,
 *             which, due to their inefficiency and complexity, are no longer
 *             being maintained and have been abandoned by the java-gnome
 *             project. This class may exist in java-gnome 4.0; look out for
 *             <code>org.freedesktop.cairo.ImageSurface</code>.
 *             As this package was never correctly implemented in java-gnome 2.x,
 *             any new code written will likely have a considerably different
 *             public API.
 */
public class ImageSurface extends Surface {

    public ImageSurface(Format format, int width, int height) {
        super(cairo_image_surface_create(format.getValue(), width, height));
    }

    public ImageSurface(char[] data, Format format, int width, int height,
            int stride) {
        super(cairo_image_surface_create_for_data(data, format.getValue(),
                width, height, stride));
    }

    ImageSurface(Handle hndl) {
        super(hndl);
    }

    public int getWidth() {
        return cairo_image_surface_get_width(getHandle());
    }

    public int getHeight() {
        return cairo_image_surface_get_height(getHandle());
    }

    static public ImageSurface createFromPNG(String filename) {
        return new ImageSurface(cairo_image_surface_create_from_png(filename));
    }

    /*
     * Native calls
     * @deprecated Superceeded by java-gnome 4.0; this method or constant
     *             will no doubt exist conceptually, but it may have a different
     *             name or signature in order that the presented API is an
     *             algorithmic mapping of the underlying native libraries.
     */
    native static final private Handle cairo_image_surface_create(int format,
            int width, int height);

    native static final private Handle cairo_image_surface_create_for_data(
            char[] data, int format, int width, int height, int stride);

    native static final private int cairo_image_surface_get_width(Handle obj);

    native static final private int cairo_image_surface_get_height(Handle obj);

    // TODO: JNI and exception handling
    native static final private Handle cairo_image_surface_create_from_png(
            String filename);
    // TODO:
    // native static final private Handle
    // cairo_image_surface_create_from_png_stream(String func);
    // cairo_surface_t *
    // cairo_image_surface_create_from_png_stream (cairo_read_func_t read_func,
    // void *closure);

}
