@@ -554,15 +554,22 @@ public Image(Device device, ImageFileNameProvider imageFileNameProvider) {
554
554
initialNativeZoom = DPIUtil .getNativeDeviceZoom ();
555
555
ElementAtZoom <String > fileName = DPIUtil .validateAndGetImagePathAtZoom (imageFileNameProvider , getZoom ());
556
556
ImageHandle imageMetadata = initNative (fileName .element (), getZoom ());
557
- if (imageMetadata == null ) {
558
- if (fileName . zoom () == getZoom () ) {
557
+ if (fileName . zoom () == getZoom () ) {
558
+ if (imageMetadata == null ) {
559
559
init (new ImageData (fileName .element ()), getZoom ());
560
+ }
561
+ } else {
562
+ ImageData imageData ;
563
+ if (imageMetadata == null ) {
564
+ imageData = new ImageData (fileName .element ());
560
565
} else {
561
- ImageData resizedData = DPIUtil .autoScaleImageData (device , new ImageData (fileName .element ()),
562
- fileName .zoom ());
563
- init (resizedData , getZoom ());
566
+ imageData = imageMetadata .getImageData ();
564
567
}
568
+ ImageData resizedData = DPIUtil .autoScaleImageData (device , imageData , fileName .zoom ());
569
+ destroyHandle ();
570
+ init (resizedData , getZoom ());
565
571
}
572
+
566
573
init ();
567
574
this .device .registerResourceWithZoomSupport (this );
568
575
}
@@ -2160,19 +2167,26 @@ ImageData getImageData(int zoom) {
2160
2167
ImageHandle getImageMetadata (int zoom ) {
2161
2168
ElementAtZoom <String > imageCandidate = DPIUtil .validateAndGetImagePathAtZoom (provider , zoom );
2162
2169
ImageHandle imageMetadata = initNative (imageCandidate .element (), zoom );
2163
- if (imageMetadata == null ) {
2164
- if (imageCandidate . zoom () == zoom ) {
2170
+ if (imageCandidate . zoom () == zoom ) {
2171
+ if (imageMetadata == null ) {
2165
2172
/* Release current native resources */
2166
2173
ImageData imageData = new ImageData (imageCandidate .element ());
2167
2174
init (imageData , zoom );
2168
2175
init ();
2176
+ }
2177
+ } else {
2178
+ ImageData imageData ;
2179
+ if (imageMetadata == null ) {
2180
+ imageData = new ImageData (imageCandidate .element ());
2169
2181
} else {
2170
- ImageData imageData = new ImageData (imageCandidate .element ());
2171
- ImageData resizedData = DPIUtil .scaleImageData (device , imageData , zoom , imageCandidate .zoom ());
2172
- ImageData newData = adaptImageDataIfDisabledOrGray (resizedData );
2173
- init (newData , zoom );
2182
+ imageData = imageMetadata .getImageData ();
2174
2183
}
2184
+ ImageData resizedData = DPIUtil .scaleImageData (device , imageData , zoom , imageCandidate .zoom ());
2185
+ ImageData newData = adaptImageDataIfDisabledOrGray (resizedData );
2186
+ destroyHandle ();
2187
+ init (newData , zoom );
2175
2188
}
2189
+
2176
2190
return zoomLevelToImageHandle .get (zoom );
2177
2191
}
2178
2192
0 commit comments