// Decompiled by DJ v2.6.6.51 Copyright 2000 Atanas Neshkov  Date: 6/15/2001 17:41:53
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   com/macromedia/generator/api/Bitmap

package com.macromedia.generator.api;

import com.macromedia.generator.api.peer.BitmapPeer;
import com.macromedia.generator.platform.Mac;

// Referenced classes of package com.macromedia.generator.api:
//            GenObject, GeneratorApiException, Rect, Buffer

public class Bitmap extends GenObject
{

    public Bitmap()
        throws GeneratorApiException
    {
        peer = BitmapPeer.New();
        if(peer == 0)
            throw new GeneratorApiException("unable to create peer");
        else
            return;
    }

    protected Bitmap(int i)
        throws GeneratorApiException
    {
        peer = i;
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        else
            return;
    }

    protected void finalize()
        throws Throwable
    {
        if(peer != 0)
            BitmapPeer.Release(peer);
        peer = 0;
    }

    public Rect getBounds()
        throws GeneratorApiException
    {
        int ai[] = new int[1];
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int i = BitmapPeer.GetBounds(peer, ai);
        if(i == 0)
            throw new GeneratorApiException("error getting bounds");
        else
            return new Rect(ai[0]);
    }

    public int getExport()
        throws GeneratorApiException
    {
        int ai[] = new int[1];
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int i = BitmapPeer.GetExport(peer, ai);
        if(i == 0)
            throw new GeneratorApiException("error getting export format");
        else
            return ai[0];
    }

    public int getHeight()
        throws GeneratorApiException
    {
        int ai[] = new int[1];
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int i = BitmapPeer.GetHeight(peer, ai);
        if(i == 0)
            throw new GeneratorApiException("error getting height");
        else
            return ai[0];
    }

    public int getQuality()
        throws GeneratorApiException
    {
        int ai[] = new int[1];
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int i = BitmapPeer.GetQuality(peer, ai);
        if(i == 0)
            throw new GeneratorApiException("error getting quality");
        else
            return ai[0];
    }

    public int getWidth()
        throws GeneratorApiException
    {
        int ai[] = new int[1];
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int i = BitmapPeer.GetWidth(peer, ai);
        if(i == 0)
            throw new GeneratorApiException("error getting width");
        else
            return ai[0];
    }

    public void release()
    {
        if(peer != 0)
            BitmapPeer.Release(peer);
        peer = 0;
    }

    public void setBuffer(Buffer buffer)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        if(buffer == null)
            throw new GeneratorApiException("null buffer");
        int i = BitmapPeer.SetBuffer(peer, buffer.peer);
        if(i == 0)
            throw new GeneratorApiException("error setting buffer");
        else
            return;
    }

    public void setCenter(int i, int j)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int k = BitmapPeer.SetCenter(peer, i, j);
        if(k == 0)
            throw new GeneratorApiException("error setting center");
        else
            return;
    }

    public void setExport(int i)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int j = BitmapPeer.SetExport(peer, i);
        if(j == 0)
            throw new GeneratorApiException("error setting export format");
        else
            return;
    }

    public void setFile(String s)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        if(s == null)
            throw new GeneratorApiException("null string");
        Mac mac = Mac.getMac();
        int i;
        if(mac != null)
        {
            String s1 = mac.makeSystemPretty(s);
            i = BitmapPeer.SetFile(peer, s1);
        } else
        {
            i = BitmapPeer.SetFile(peer, s);
        }
        if(i == 0)
            throw new GeneratorApiException("error setting file");
        else
            return;
    }

    public void setPngBuffer(Buffer buffer)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        if(buffer == null)
            throw new GeneratorApiException("null buffer");
        int i = BitmapPeer.SetPngBuffer(peer, buffer.peer);
        if(i == 0)
            throw new GeneratorApiException("error setting buffer");
        else
            return;
    }

    public void setPngFile(String s)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        if(s == null)
            throw new GeneratorApiException("null string");
        Mac mac = Mac.getMac();
        int i;
        if(mac != null)
        {
            String s1 = mac.makeSystemPretty(s);
            i = BitmapPeer.SetPngFile(peer, s1);
        } else
        {
            i = BitmapPeer.SetPngFile(peer, s);
        }
        if(i == 0)
            throw new GeneratorApiException("error setting file");
        else
            return;
    }

    public void setQuality(int i)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int j = BitmapPeer.SetQuality(peer, i);
        if(j == 0)
            throw new GeneratorApiException("error setting quality");
        else
            return;
    }
}