Skip to content

Commit 0fc4d17

Browse files
author
pdavidc
committed
Renamed ImageOptions.imageFormat as ImageOptions.imageConfig to disambiguate it from retrieval format
1 parent e2a8463 commit 0fc4d17

File tree

8 files changed

+29
-40
lines changed

8 files changed

+29
-40
lines changed

worldwind-examples/src/main/java/gov/nasa/worldwindx/experimental/AtmosphereLayer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public AtmosphereLayer() {
4545
this.setDisplayName("Atmosphere");
4646
this.setPickEnabled(false);
4747
this.nightImageSource = ImageSource.fromResource(R.drawable.dnb_land_ocean_ice_2012);
48-
this.nightImageOptions = ImageOptions.fromImageFormat(WorldWind.IMAGE_FORMAT_RGB_565);
48+
this.nightImageOptions = new ImageOptions(WorldWind.RGB_565);
4949
}
5050

5151
public ImageSource getNightImageSource() {

worldwind/src/main/java/gov/nasa/worldwind/WorldWind.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -134,24 +134,24 @@ public class WorldWind {
134134
}
135135

136136
/**
137-
* {@link ImageFormat} constant indicating 32-bit RGBA_8888 image format.
137+
* {@link ImageConfig} constant indicating 32-bit RGBA_8888 image configuration.
138138
*/
139-
public static final int IMAGE_FORMAT_RGBA_8888 = 0;
139+
public static final int RGBA_8888 = 0;
140140

141141
/**
142-
* {@link ImageFormat} constant indicating 16-bit RGBA_565 image format.
142+
* {@link ImageConfig} constant indicating 16-bit RGBA_565 image configuration.
143143
*/
144-
public static final int IMAGE_FORMAT_RGB_565 = 1;
144+
public static final int RGB_565 = 1;
145145

146146
/**
147-
* Image format indicates the in-memory representation for images displayed by World Wind components. Images are
148-
* typically represented in the 32-bit RGBA_8888 format, the highest quality available. Components that do not
149-
* require an alpha channel and want to conserve memory may use the 16-bit RGBA_565 format. Accepted values are
150-
* {@link #IMAGE_FORMAT_RGBA_8888} and {@link #IMAGE_FORMAT_RGB_565}.
147+
* Image config indicates the in-memory representation for images displayed by World Wind components. Images are
148+
* typically represented in the 32-bit RGBA_8888 configuration, the highest quality available. Components that do
149+
* not require an alpha channel and want to conserve memory may use the 16-bit RGBA_565 configuration. Accepted
150+
* values are {@link #RGBA_8888} and {@link #RGB_565}.
151151
*/
152-
@IntDef({IMAGE_FORMAT_RGBA_8888, IMAGE_FORMAT_RGB_565})
152+
@IntDef({RGBA_8888, RGB_565})
153153
@Retention(RetentionPolicy.SOURCE)
154-
public @interface ImageFormat {
154+
public @interface ImageConfig {
155155

156156
}
157157

worldwind/src/main/java/gov/nasa/worldwind/layer/BackgroundLayer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class BackgroundLayer extends RenderableLayer {
2626
* associated with the World Window.
2727
*/
2828
public BackgroundLayer() {
29-
this(ImageSource.fromResource(R.drawable.gov_nasa_worldwind_worldtopobathy2004053), ImageOptions.fromImageFormat(WorldWind.IMAGE_FORMAT_RGB_565));
29+
this(ImageSource.fromResource(R.drawable.gov_nasa_worldwind_worldtopobathy2004053), new ImageOptions(WorldWind.RGB_565));
3030
}
3131

3232
/**

worldwind/src/main/java/gov/nasa/worldwind/layer/BlueMarbleLandsatLayer.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,6 @@ public BlueMarbleLandsatLayer(String serviceAddress) {
6464
landsatConfig.transparent = false; // combining BlueMarble and esat layers results in opaque images
6565
this.landsatUrlFactory = new WmsGetMapUrlFactory(landsatConfig);
6666

67-
// Configure this layer's image options to reduce memory usage by using a 16-bit format with no alpha.
68-
ImageOptions imageOptions = new ImageOptions();
69-
imageOptions.imageFormat = WorldWind.IMAGE_FORMAT_RGB_565;
70-
7167
// Configure this layer's level set to capture the entire globe at 15m resolution.
7268
double metersPerPixel = 15;
7369
double radiansPerPixel = metersPerPixel / WorldWind.WGS84_SEMI_MAJOR_AXIS;
@@ -78,7 +74,7 @@ public BlueMarbleLandsatLayer(String serviceAddress) {
7874
this.setLevelSet(new LevelSet(levelsConfig));
7975
this.setTileUrlFactory(this);
8076
this.setImageFormat("image/png");
81-
this.setImageOptions(imageOptions);
77+
this.setImageOptions(new ImageOptions(WorldWind.RGB_565)); // reduce memory usage by using a 16-bit configuration with no alpha
8278
}
8379

8480
@Override

worldwind/src/main/java/gov/nasa/worldwind/layer/BlueMarbleLayer.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,8 @@ public BlueMarbleLayer(String serviceAddress) {
4848
config.coordinateSystem = "EPSG:4326";
4949
config.transparent = false; // the BlueMarble layer is opaque
5050

51-
ImageOptions imageOptions = new ImageOptions();
52-
imageOptions.imageFormat = WorldWind.IMAGE_FORMAT_RGB_565; // exploit opaque imagery to reduce memory usage
53-
5451
this.setDisplayName("Blue Marble");
5552
this.setConfiguration(new Sector().setFullSphere(), 500, config); // 500m resolution on Earth
56-
this.setImageOptions(imageOptions);
53+
this.setImageOptions(new ImageOptions(WorldWind.RGB_565)); // exploit opaque imagery to reduce memory usage
5754
}
5855
}

worldwind/src/main/java/gov/nasa/worldwind/render/ImageOptions.java

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
public class ImageOptions {
1414

1515
/**
16-
* Indicates the in-memory representation for images displayed by World Wind components. By default, images are
17-
* represented in the 32-bit RGBA_8888 format, the highest quality available. Components that do not require an
18-
* alpha channel and want to conserve memory may use the 16-bit RGBA_565 format. Accepted values are {@link
19-
* WorldWind#IMAGE_FORMAT_RGBA_8888} and {@link WorldWind#IMAGE_FORMAT_RGB_565}.
16+
* Indicates the in-memory configuration for images displayed by World Wind components. By default, images are
17+
* represented in the 32-bit RGBA_8888 configuration, the highest quality available. Components that do not require
18+
* an alpha channel and want to conserve memory may use the 16-bit RGBA_565 configuration. Accepted values are
19+
* {@link WorldWind#RGBA_8888} and {@link WorldWind#RGB_565}.
2020
*/
21-
@WorldWind.ImageFormat
22-
public int imageFormat = WorldWind.IMAGE_FORMAT_RGBA_8888;
21+
@WorldWind.ImageConfig
22+
public int imageConfig = WorldWind.RGBA_8888;
2323

2424
/**
2525
* Constructs an image options with default values.
@@ -28,16 +28,12 @@ public ImageOptions() {
2828
}
2929

3030
/**
31-
* Constructs an image options with an image format.
31+
* Constructs an image options with an image configuration.
3232
*
33-
* @param imageFormat the image format to use. Accepted values are {@link WorldWind#IMAGE_FORMAT_RGBA_8888} and
34-
* {@link WorldWind#IMAGE_FORMAT_RGB_565}.
35-
*
36-
* @return the new image options
33+
* @param imageConfig the image configuration to use. Accepted values are {@link WorldWind#RGBA_8888} and {@link
34+
* WorldWind#RGB_565}.
3735
*/
38-
public static ImageOptions fromImageFormat(@WorldWind.ImageFormat int imageFormat) {
39-
ImageOptions imageOptions = new ImageOptions();
40-
imageOptions.imageFormat = imageFormat;
41-
return imageOptions;
36+
public ImageOptions(@WorldWind.ImageConfig int imageConfig) {
37+
this.imageConfig = imageConfig;
4238
}
4339
}

worldwind/src/main/java/gov/nasa/worldwind/render/ImageRetriever.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,11 @@ protected BitmapFactory.Options bitmapFactoryOptions(ImageOptions imageOptions)
118118
factoryOptions.inScaled = false; // suppress default image scaling; load the image in its native dimensions
119119

120120
if (imageOptions != null) {
121-
switch (imageOptions.imageFormat) {
122-
case WorldWind.IMAGE_FORMAT_RGBA_8888:
121+
switch (imageOptions.imageConfig) {
122+
case WorldWind.RGBA_8888:
123123
factoryOptions.inPreferredConfig = Bitmap.Config.ARGB_8888;
124124
break;
125-
case WorldWind.IMAGE_FORMAT_RGB_565:
125+
case WorldWind.RGB_565:
126126
factoryOptions.inPreferredConfig = Bitmap.Config.RGB_565;
127127
break;
128128
}

worldwind/src/main/java/gov/nasa/worldwind/render/RenderResourceCache.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public static int recommendedCapacity(Context context) {
7171
if (am != null) {
7272
ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
7373
am.getMemoryInfo(mi);
74-
if (mi.totalMem >= 1024 * 1024 * 2048L) { // use 384 MB on machines with 1536 MB or more
74+
if (mi.totalMem >= 1024 * 1024 * 2048L) { // use 384 MB on machines with 2048 MB or more
7575
return 1024 * 1024 * 384;
7676
} else if (mi.totalMem >= 1024 * 1024 * 1536) { // use 256 MB on machines with 1536 MB or more
7777
return 1024 * 1024 * 256;

0 commit comments

Comments
 (0)