/** * Constructs a background image layer with an image source. The image's dimensions must be no greater than 2048 x * 2048. * * @param imageSource the image source * @param imageOptions the image options, or null to use the default options * * @throws IllegalArgumentException If the image source is null */ public BackgroundLayer(ImageSource imageSource, ImageOptions imageOptions) { if (imageSource == null) { throw new IllegalArgumentException( Logger.logMessage(Logger.ERROR, "BackgroundLayer", "constructor", "missingSource")); } this.setDisplayName("Background"); // Disable picking for the layer because it covers the full sphere and will override a terrain pick. this.setPickEnabled(false); // Delegate display to the SurfaceImage shape. SurfaceImage surfaceImage = new SurfaceImage(new Sector().setFullSphere(), imageSource); surfaceImage.setImageOptions(imageOptions); this.addRenderable(surfaceImage); } }
SurfaceImage surfaceImageResource = new SurfaceImage(sector, ImageSource.fromResource(resourceId)); SurfaceImage surfaceImageUrl = new SurfaceImage(sector, 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); }