@@ -845,21 +845,15 @@ ImageHandle getHandle (int targetZoom, int nativeZoom) {
845845 return getImageMetadata (zoomContext );
846846}
847847
848- @ FunctionalInterface
849- interface HandleAtSizeConsumer {
850- void accept (ImageHandle imageHandle , Point handleSize );
851- }
852-
853- void executeOnImageHandleAtSize (HandleAtSizeConsumer handleAtSizeConsumer , int widthHint , int heightHint ) {
848+ void executeOnImageHandleAtBestFittingSize (Consumer <ImageHandle > handleAtSizeConsumer , int widthHint , int heightHint ) {
854849 if (!lastRequestedHandle .isReusable (heightHint , widthHint )) {
855850 ImageData imageData ;
856851 imageData = this .imageProvider .loadImageDataAtSize (widthHint , heightHint );
857852 lastRequestedHandle .destroy ();
858853 ImageHandle handleContainer = init (imageData , -1 );
859854 lastRequestedHandle = new CachedHandle (handleContainer , widthHint , heightHint );
860855 }
861- handleAtSizeConsumer .accept (lastRequestedHandle .getHandle (),
862- new Point (lastRequestedHandle .handleContainer ().width , lastRequestedHandle .handleContainer ().height ));
856+ handleAtSizeConsumer .accept (lastRequestedHandle .getHandle ());
863857}
864858
865859/**
@@ -2817,13 +2811,15 @@ public void internal_dispose_GC(long handle, GCData data) {
28172811class ImageHandle {
28182812 private long handle ;
28192813 private final int zoom ;
2820- private int height ;
2821- private int width ;
2814+ private final int height ;
2815+ private final int width ;
28222816
2823- public ImageHandle (long handle , int zoom ) {
2817+ ImageHandle (long handle , int zoom ) {
28242818 this .handle = handle ;
28252819 this .zoom = zoom ;
2826- updateBoundsInPixelsFromNative ();
2820+ Point bounds = getBoundsInPixelsFromNative ();
2821+ this .width = bounds .x ;
2822+ this .height = bounds .y ;
28272823 if (backgroundColor != null ) {
28282824 setBackground (backgroundColor );
28292825 }
@@ -2834,7 +2830,15 @@ long getHandle() {
28342830 return handle ;
28352831 }
28362832
2837- public Rectangle getBounds () {
2833+ int getWidth () {
2834+ return width ;
2835+ }
2836+
2837+ int getHeight () {
2838+ return height ;
2839+ }
2840+
2841+ Rectangle getBounds () {
28382842 return new Rectangle (0 , 0 , width , height );
28392843 }
28402844
@@ -2863,14 +2867,12 @@ private void setBackground(RGB color) {
28632867 device .internal_dispose_GC (hDC , null );
28642868 }
28652869
2866- private void updateBoundsInPixelsFromNative () {
2870+ private Point getBoundsInPixelsFromNative () {
28672871 switch (type ) {
28682872 case SWT .BITMAP :
28692873 BITMAP bm = new BITMAP ();
28702874 OS .GetObject (handle , BITMAP .sizeof , bm );
2871- width = bm .bmWidth ;
2872- height = bm .bmHeight ;
2873- return ;
2875+ return new Point (bm .bmWidth , bm .bmHeight );
28742876 case SWT .ICON :
28752877 ICONINFO info = new ICONINFO ();
28762878 OS .GetIconInfo (handle , info );
@@ -2881,11 +2883,10 @@ private void updateBoundsInPixelsFromNative() {
28812883 if (hBitmap == info .hbmMask ) bm .bmHeight /= 2 ;
28822884 if (info .hbmColor != 0 ) OS .DeleteObject (info .hbmColor );
28832885 if (info .hbmMask != 0 ) OS .DeleteObject (info .hbmMask );
2884- width = bm .bmWidth ;
2885- height = bm .bmHeight ;
2886- return ;
2886+ return new Point (bm .bmWidth , bm .bmHeight );
28872887 default :
28882888 SWT .error (SWT .ERROR_INVALID_IMAGE );
2889+ return null ;
28892890 }
28902891 }
28912892
0 commit comments