return fromBitmap((Bitmap) source); } else if (source instanceof ImageSource.BitmapFactory) { return fromBitmapFactory((ImageSource.BitmapFactory) source); } else if (source instanceof Integer) { // Android resource identifier, as generated by the aapt tool return fromResource((Integer) source); } else if (source instanceof String && WWUtil.isUrlString((String) source)) { return fromUrl((String) source); } else if (source instanceof String) { return fromFilePath((String) source); } else { ImageSource imageSource = new ImageSource(); imageSource.type = TYPE_UNRECOGNIZED; imageSource.source = source;
protected Bitmap decodeImage(ImageSource imageSource, ImageOptions imageOptions) throws IOException { if (imageSource.isBitmap()) { return imageSource.asBitmap(); } if (imageSource.isBitmapFactory()) { return imageSource.asBitmapFactory().createBitmap(); } if (imageSource.isResource()) { return this.decodeResource(imageSource.asResource(), imageOptions); } if (imageSource.isFilePath()) { return this.decodeFilePath(imageSource.asFilePath(), imageOptions); } if (imageSource.isUrl()) { return this.decodeUrl(imageSource.asUrl(), imageOptions); } return this.decodeUnrecognized(imageSource); }
/** * Constructs a Blue Marble background layer with the built-in WorldWind library resource * res/drawable/gov_nasa_worldwind_worldtopobathy2004053. The resource must be accessible from the Android Context * associated with the WorldWindow. */ public BackgroundLayer() { this(ImageSource.fromResource(R.drawable.gov_nasa_worldwind_worldtopobathy2004053), new ImageOptions(WorldWind.RGB_565)); }
SurfaceImage surfaceImageResource = new SurfaceImage(sector, ImageSource.fromResource(resourceId)); SurfaceImage surfaceImageUrl = new SurfaceImage(sector, ImageSource.fromUrl(urlString));
PlacemarkAttributes.createWithImageAndLeader(ImageSource.fromResource(R.drawable.aircraft_fixwing)).setImageScale(1.5)); PlacemarkAttributes.createWithImage(ImageSource.fromResource(R.drawable.airport_terminal)).setImageOffset(Offset.bottomCenter()).setImageScale(2), "Oxnard Airport"); Placemark wildfire = new Placemark( Position.fromDegrees(34.300, -119.25, 0), PlacemarkAttributes.createWithImage(ImageSource.fromBitmap(bitmap)).setImageOffset(Offset.bottomCenter()));
@Override public ImageSource createTileSource(TileMatrix tileMatrix, int row, int column) { String urlString = this.urlForTile(tileMatrix, row, column); return ImageSource.fromUrl(urlString); }
Path path = new Path(positions); ShapeAttributes sa = new ShapeAttributes(thickenLine); sa.setOutlineImageSource(ImageSource.fromLineStipple(2 /*factor*/, (short) 0xF0F0 /*pattern*/)); path.setAttributes(sa); layer.addRenderable(path); path = new Path(positions); sa = new ShapeAttributes(thickenLine); sa.setOutlineImageSource(ImageSource.fromLineStipple(4 /*factor*/, (short) 0xF0F0 /*pattern*/)); path.setAttributes(sa); layer.addRenderable(path); path = new Path(positions); sa = new ShapeAttributes(thickenLine); sa.setOutlineImageSource(ImageSource.fromLineStipple(8 /*factor*/, (short) 0xDFF6 /*pattern*/)); path.setAttributes(sa); path.setAltitudeMode(WorldWind.CLAMP_TO_GROUND); Ellipse ellipse = new Ellipse(ellipseCenter, 1.5e6, 800e3); sa = new ShapeAttributes(thickenLine); sa.setInteriorImageSource(ImageSource.fromResource(R.drawable.pattern_sample_houndstooth)); ellipse.setAttributes(sa); layer.addRenderable(ellipse); Polygon polygon = new Polygon(positions); sa = new ShapeAttributes(thickenLine); sa.setInteriorImageSource(ImageSource.fromResource(R.drawable.pattern_sample_houndstooth)); sa.setOutlineImageSource(ImageSource.fromLineStipple(8, (short) 0xDFF6)); polygon.setAttributes(sa);
/** * Creates a placemark attributes bundle containing a MIL-STD-2525 symbol using the specified modifiers and * attributes. The ImageSource bitmap is lazily created via an ImageSource.Bitmap factory. The call to the * factory's createBitmap method made when Placemark comes into view; it's also used to recreate the bitmap if the * resource was evicted from the WorldWind render resource cache. * * @param symbolCode The 15-character SIDC (symbol identification coding scheme) code. * @param modifiers The ModifierUnit (unit) or ModifierTG (tactical graphic) modifiers collection. May be null. * @param attributes The MilStdAttributes attributes collection. May be null. * * @return A new PlacemarkAttributes bundle representing the MIL-STD-2525 symbol. */ public static PlacemarkAttributes createPlacemarkAttributes(String symbolCode, SparseArray<String> modifiers, SparseArray<String> attributes) { PlacemarkAttributes placemarkAttributes = new PlacemarkAttributes(); // Create a BitmapFactory instance with the values needed to create and recreate the symbol's bitmap SymbolBitmapFactory factory = new SymbolBitmapFactory(symbolCode, modifiers, attributes, placemarkAttributes); placemarkAttributes.setImageSource(ImageSource.fromBitmapFactory(factory)); return placemarkAttributes; }
/** * Constructs an image source with an Android resource identifier. The resource must be accessible from the Android * Context associated with the WorldWindow, and its dimensions should be no greater than 2048 x 2048. * * @param id the resource identifier, as generated by the aapt tool * * @return the new image source */ public static ImageSource fromResource(@DrawableRes int id) { ImageSource imageSource = new ImageSource(); imageSource.type = TYPE_RESOURCE; imageSource.source = id; return imageSource; }
PlacemarkAttributes.createWithImage(ImageSource.fromResource(R.drawable.aircraft_fixwing)), PlacemarkAttributes.createWithImage(ImageSource.fromResource(R.drawable.airplane)), PlacemarkAttributes.createWithImage(ImageSource.fromResource(R.drawable.airport)), PlacemarkAttributes.createWithImage(ImageSource.fromResource(R.drawable.airport_terminal))};
@Override public ImageSource createTileSource(TileMatrix tileMatrix, int row, int column) { String urlString = this.urlForTile(tileMatrix, row, column); return ImageSource.fromUrl(urlString); }
tile.setImageSource(ImageSource.fromBitmapFactory(bitmapFactory));
/** * Constructs an image source with a bitmap. The bitmap's dimensions should be no greater than 2048 x 2048. * * @param bitmap the bitmap to use as an image source * * @return the new image source * * @throws IllegalArgumentException If the bitmap is null or recycled */ public static ImageSource fromBitmap(Bitmap bitmap) { if (bitmap == null || bitmap.isRecycled()) { throw new IllegalArgumentException( Logger.logMessage(Logger.ERROR, "ImageSource", "fromBitmap", (bitmap == null) ? "missingBitmap" : "invalidBitmap")); } ImageSource imageSource = new ImageSource(); imageSource.type = TYPE_BITMAP; imageSource.source = bitmap; return imageSource; }
public AtmosphereLayer() { this.setDisplayName("Atmosphere"); this.setPickEnabled(false); this.nightImageSource = ImageSource.fromResource(R.drawable.dnb_land_ocean_ice_2012); this.nightImageOptions = new ImageOptions(WorldWind.RGB_565); }
@Override public ImageSource createTileSource(TileMatrix tileMatrix, int row, int column) { Sector sector = tileMatrix.tileSector(row, column); String urlString = wmsTileFactory.urlForTile(sector, tileMatrix.tileWidth, tileMatrix.tileHeight); return ImageSource.fromUrl(urlString); } });
protected boolean addImage() { // Create an image source with a unique factory instance. This pattern is used in order to force WorldWind to // allocate a new OpenGL texture object for each surface image from a single bitmap instance. ImageSource imageSource = ImageSource.fromBitmapFactory(new ImageSource.BitmapFactory() { @Override public Bitmap createBitmap() { return bitmap; } }); // Add the surface image to this test's layer. this.layer.addRenderable(new SurfaceImage(new Sector(this.sector), imageSource)); this.getWorldWindow().requestRedraw(); // Advance to the next surface image's location. if (this.sector.maxLongitude() < this.firstSector.minLongitude() + this.firstSector.deltaLongitude() * 20) { this.sector.set( this.sector.minLatitude(), this.sector.minLongitude() + this.sector.deltaLongitude() + 0.1, this.sector.deltaLatitude(), this.sector.deltaLongitude()); } else { this.sector.set( this.sector.minLatitude() + this.sector.deltaLatitude() + 0.1, this.firstSector.minLongitude(), this.sector.deltaLatitude(), this.sector.deltaLongitude()); } // Add another image after the configured delay. return this.handler.sendEmptyMessageDelayed(ADD_IMAGE, ADD_IMAGE_DELAY); }
/** * Constructs an image source with a file path. * * @param pathName complete path name to the file * * @return the new image source * * @throws IllegalArgumentException If the path name is null */ public static ImageSource fromFilePath(String pathName) { if (pathName == null) { throw new IllegalArgumentException( Logger.logMessage(Logger.ERROR, "ImageSource", "fromFilePath", "missingPathName")); } ImageSource imageSource = new ImageSource(); imageSource.type = TYPE_FILE_PATH; imageSource.source = pathName; return imageSource; }
protected static PlacemarkAttributes createPlacemarkAttributes(Resources resources, @DrawableRes int resourceId, double scale) { PlacemarkAttributes placemarkAttributes = new PlacemarkAttributes(); // Create a BitmapFactory instance with the values needed to create and recreate the symbol's bitmap //IconBitmapFactory factory = new IconBitmapFactory(resources, resourceId); //placemarkAttributes.setImageSource(ImageSource.fromBitmapFactory(factory)).setImageScale(scale); placemarkAttributes.setImageSource(ImageSource.fromResource(resourceId)).setImageScale(scale).setMinimumImageScale(0.5); return placemarkAttributes; } }
@Override public Tile createTile(Sector sector, Level level, int row, int column) { ImageTile tile = new ImageTile(sector, level, row, column); String urlString = this.urlForTile(level.levelNumber, row, column); if (urlString != null) { tile.setImageSource(ImageSource.fromUrl(urlString)); } return tile; }