public static TrimmedObjectTileSet trimObjectTileSet (
        ObjectTileSet source, OutputStream destImage, String imgFormat)
        throws IOException
    {
        final TrimmedObjectTileSet tset = new TrimmedObjectTileSet();
        tset.setName(source.getName());
        int tcount = source.getTileCount();

//         System.out.println("Trimming object tile set [source=" + source + "].");

        // create our metrics arrays
        tset._bounds = new Rectangle[tcount];
        tset._ometrics = new Rectangle[tcount];

        // create our bits if needed
        if (source._priorities != null ||
            source._xspots != null ||
            source._constraints != null) {
            tset._bits = new Bits[tcount];
        }

        // copy our colorizations
        tset._zations = source.getColorizations();

        // fill in the original object metrics
        for (int ii = 0; ii < tcount; ii++) {
            tset._ometrics[ii] = new Rectangle();
            if (source._xorigins != null) {
                tset._ometrics[ii].x = source._xorigins[ii];
            }
            if (source._yorigins != null) {
                tset._ometrics[ii].y = source._yorigins[ii];
            }
            tset._ometrics[ii].width = source._owidths[ii];
            tset._ometrics[ii].height = source._oheights[ii];

            // fill in our bits
            if (tset._bits != null) {
                tset._bits[ii] = new Bits();
            }
            if (source._priorities != null) {
                tset._bits[ii].priority = source._priorities[ii];
            }
            if (source._xspots != null) {
                tset._bits[ii].xspot = source._xspots[ii];
                tset._bits[ii].yspot = source._yspots[ii];
                tset._bits[ii].sorient = source._sorients[ii];
            }
            if (source._constraints != null) {
                tset._bits[ii].constraints = source._constraints[ii];
            }
        }

        // create the trimmed tileset image
        TileSetTrimmer.TrimMetricsReceiver tmr = new TileSetTrimmer.TrimMetricsReceiver() {
            public void trimmedTile (int tileIndex, int imageX, int imageY,
                                     int trimX, int trimY, int trimWidth, int trimHeight) {
                tset._ometrics[tileIndex].x -= trimX;
                tset._ometrics[tileIndex].y -= trimY;
                tset._bounds[tileIndex] = new Rectangle(imageX, imageY, trimWidth, trimHeight);
            }
        };
        TileSetTrimmer.trimTileSet(source, destImage, tmr, imgFormat);

//         Log.info("Trimmed object tileset [bounds=" + StringUtil.toString(tset._bounds) +
//                  ", metrics=" + StringUtil.toString(tset._ometrics) + "].");

        return tset;
    }
public static TrimmedObjectTileSet trimObjectTileSet ( ObjectTileSet source , OutputStream destImage , String imgFormat ) throws IOException { final TrimmedObjectTileSet tset = new TrimmedObjectTileSet ( ) ; tset . setName ( source . getName ( ) ) ; int tcount = source . getTileCount ( ) ; tset . _bounds = new Rectangle [ tcount ] ; tset . _ometrics = new Rectangle [ tcount ] ; if ( source . _priorities != null || source . _xspots != null || source . _constraints != null ) { tset . _bits = new Bits [ tcount ] ; } tset . _zations = source . getColorizations ( ) ; for ( int ii = 0 ; ii < tcount ; ii ++ ) { tset . _ometrics [ ii ] = new Rectangle ( ) ; if ( source . _xorigins != null ) { tset . _ometrics [ ii ] . x = source . _xorigins [ ii ] ; } if ( source . _yorigins != null ) { tset . _ometrics [ ii ] . y = source . _yorigins [ ii ] ; } tset . _ometrics [ ii ] . width = source . _owidths [ ii ] ; tset . _ometrics [ ii ] . height = source . _oheights [ ii ] ; if ( tset . _bits != null ) { tset . _bits [ ii ] = new Bits ( ) ; } if ( source . _priorities != null ) { tset . _bits [ ii ] . priority = source . _priorities [ ii ] ; } if ( source . _xspots != null ) { tset . _bits [ ii ] . xspot = source . _xspots [ ii ] ; tset . _bits [ ii ] . yspot = source . _yspots [ ii ] ; tset . _bits [ ii ] . sorient = source . _sorients [ ii ] ; } if ( source . _constraints != null ) { tset . _bits [ ii ] . constraints = source . _constraints [ ii ] ; } } TileSetTrimmer . TrimMetricsReceiver tmr = new TileSetTrimmer . TrimMetricsReceiver ( ) { public void trimmedTile ( int tileIndex , int imageX , int imageY , int trimX , int trimY , int trimWidth , int trimHeight ) { tset . _ometrics [ tileIndex ] . x -= trimX ; tset . _ometrics [ tileIndex ] . y -= trimY ; tset . _bounds [ tileIndex ] = new Rectangle ( imageX , imageY , trimWidth , trimHeight ) ; } } ; TileSetTrimmer . trimTileSet ( source , destImage , tmr , imgFormat ) ; return tset ; }
Creates a trimmed object tileset from the supplied source object tileset. The image path
must be set by hand to the appropriate path based on where the image data that is written to
the <code>destImage</code> parameter is actually stored on the file system. If imgFormat is
null, uses FastImageIO to save the file.  See {@link TileSetTrimmer#trimTileSet} for further
information.