FileDocCategorySizeDatePackage
ScreenToPNG.javaAPI DocExample2724Wed Nov 10 13:03:46 GMT 2004com.oreilly.qtjnotebook.ch05

ScreenToPNG

public class ScreenToPNG extends Object

Fields Summary
Constructors Summary
public ScreenToPNG()

        try {
            QTSessionCheck.check();

            GDevice gd = GDevice.getMain();
            System.out.println ("Got GDevice: " + gd);
            PixMap pm = gd.getPixMap();
            System.out.println ("Got PixMap: " + pm);
            ImageDescription id = new ImageDescription (pm);
            System.out.println ("Got ImageDescription: " + id);
            QDRect bounds = pm.getBounds();
            RawEncodedImage rei = pm.getPixelData();

            QDGraphics decompGW = new QDGraphics (id, 0);
            QTImage.decompress (rei,
                                id,
                                decompGW,
                                bounds,
                                0);

            GraphicsExporter exporter =
                new GraphicsExporter (StdQTConstants4.kQTFileTypePNG);
            exporter.setInputPixmap (decompGW);
            QTFile outFile = new QTFile (new java.io.File ("screen.png"));
            exporter.setOutputFile (outFile);
            System.out.println ("Exported " + 
                                exporter.doExport() +
                                " bytes");
            
        } catch (QTException qte) {
            qte.printStackTrace();
        }
        System.exit(0);

    
Methods Summary
public static voidmain(java.lang.String[] args)

        new ScreenToPNG();