@@ -554,15 +554,22 @@ public Image(Device device, ImageFileNameProvider imageFileNameProvider) {
554554 initialNativeZoom = DPIUtil .getNativeDeviceZoom ();
555555 ElementAtZoom <String > fileName = DPIUtil .validateAndGetImagePathAtZoom (imageFileNameProvider , getZoom ());
556556 ImageHandle imageMetadata = initNative (fileName .element (), getZoom ());
557- if (imageMetadata == null ) {
558- if (fileName . zoom () == getZoom () ) {
557+ if (fileName . zoom () == getZoom () ) {
558+ if (imageMetadata == null ) {
559559 init (new ImageData (fileName .element ()), getZoom ());
560+ }
561+ } else {
562+ ImageData imageData ;
563+ if (imageMetadata == null ) {
564+ imageData = new ImageData (fileName .element ());
560565 } else {
561- ImageData resizedData = DPIUtil .autoScaleImageData (device , new ImageData (fileName .element ()),
562- fileName .zoom ());
563- init (resizedData , getZoom ());
566+ imageData = imageMetadata .getImageData ();
564567 }
568+ ImageData resizedData = DPIUtil .autoScaleImageData (device , imageData , fileName .zoom ());
569+ destroyHandle ();
570+ init (resizedData , getZoom ());
565571 }
572+
566573 init ();
567574 this .device .registerResourceWithZoomSupport (this );
568575}
@@ -2160,19 +2167,26 @@ ImageData getImageData(int zoom) {
21602167 ImageHandle getImageMetadata (int zoom ) {
21612168 ElementAtZoom <String > imageCandidate = DPIUtil .validateAndGetImagePathAtZoom (provider , zoom );
21622169 ImageHandle imageMetadata = initNative (imageCandidate .element (), zoom );
2163- if (imageMetadata == null ) {
2164- if (imageCandidate . zoom () == zoom ) {
2170+ if (imageCandidate . zoom () == zoom ) {
2171+ if (imageMetadata == null ) {
21652172 /* Release current native resources */
21662173 ImageData imageData = new ImageData (imageCandidate .element ());
21672174 init (imageData , zoom );
21682175 init ();
2176+ }
2177+ } else {
2178+ ImageData imageData ;
2179+ if (imageMetadata == null ) {
2180+ imageData = new ImageData (imageCandidate .element ());
21692181 } 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 ();
21742183 }
2184+ ImageData resizedData = DPIUtil .scaleImageData (device , imageData , zoom , imageCandidate .zoom ());
2185+ ImageData newData = adaptImageDataIfDisabledOrGray (resizedData );
2186+ destroyHandle ();
2187+ init (newData , zoom );
21752188 }
2189+
21762190 return zoomLevelToImageHandle .get (zoom );
21772191 }
21782192
0 commit comments