swarm-support
[Top][All Lists]
Advanced

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

RE: Images


From: Katherine Roberts
Subject: RE: Images
Date: Tue, 27 Mar 2001 16:03:00 +0100

I've tried running the Pixmap example below. It compiles fine, but it never
gets past setting up the colormap in the buildObjects() method. Does anyone
know why this is, and what can be done to make it run proerly?
Thanks,
Katherine

-----Original Message-----
From: address@hidden
[mailto:address@hidden Behalf Of Marcus G. Daniels
Sent: 14 March 2001 17:13
To: address@hidden
Subject: Re: Images


>>>>> "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.



                  ==================================
   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]