swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Images


From: Marcus G. Daniels
Subject: Re: Images
Date: 14 Mar 2001 09:12:49 -0800
User-agent: Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.4

>>>>> "KR" == Katherine Roberts <address@hidden> writes:

KR> The thing is... I'm writing it in Java. Are there any equivalent
KR> methods to write colour images to a raster in Java? 

Yes, it works in today's snapshot:

  ftp://ftp.swarm.org/pub/swarm/src/testing/swarm-2001-03-14.tar.gz

import swarm.Globals;
import swarm.simtoolsgui.GUISwarmImpl;
import swarm.gui.PixmapCImpl;
import swarm.gui.PixmapImpl;
import swarm.gui.PixmapC;
import swarm.gui.Pixmap;
import swarm.gui.Raster;
import swarm.gui.RasterImpl;
import swarm.gui.ColormapImpl;
import swarm.gui.Colormap;
import swarm.defobj.Zone;

public class TestPixmap extends GUISwarmImpl {
    static void main (String args[]) {
        Globals.env.initSwarm ("TestCanvas", "0.0", "address@hidden",
                               args);

        TestPixmap testPixmap = new TestPixmap (Globals.env.globalZone);

        testPixmap.buildObjects ();
        testPixmap.buildActions ();
        testPixmap.activateIn (null);
        testPixmap.go ();
    }

    public TestPixmap (Zone aZone) {
        super (aZone);
    }

    public Object buildObjects () {
        super.buildObjects ();

        Colormap colormap = new ColormapImpl (getZone ());
        colormap.setColor$ToName ((byte) 0, "red");

        Raster r = new RasterImpl (getZone ());
        r.setWindowTitle ("My raster");
        r.setWidth$Height (200, 200);
        r.erase ();
        r.setColormap (colormap);
        r.pack ();
        
        PixmapC pixmapC = new PixmapCImpl (new PixmapImpl ());

        pixmapC.createBegin (getZone ());
        String appDir = Globals.env.arguments.getAppDataPath ();

        pixmapC.setDirectory (appDir);
        pixmapC.setFile ("ant.png");
        Pixmap pixmap = (Pixmap) pixmapC.createEnd ();
        pixmap.setRaster (r);

        pixmap.drawX$Y (50, 50);

        return this;
    }
}

                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]