@@ -132,11 +132,6 @@ public final class Image extends Resource implements Drawable {
132
132
*/
133
133
private RGB backgroundColor ;
134
134
135
- /**
136
- * Attribute to cache current native zoom level
137
- */
138
- private int initialNativeZoom = 100 ;
139
-
140
135
/**
141
136
* specifies the default scanline padding
142
137
*/
@@ -146,7 +141,6 @@ public final class Image extends Resource implements Drawable {
146
141
147
142
private Image (Device device , int type , long handle , int nativeZoom ) {
148
143
super (device );
149
- initialNativeZoom = nativeZoom ;
150
144
this .type = type ;
151
145
this .imageProvider = new ExistingImageHandleProviderWrapper (handle , nativeZoom );
152
146
this .isInitialized = true ;
@@ -189,13 +183,7 @@ private Image (Device device, int type, long handle, int nativeZoom) {
189
183
* @see #dispose()
190
184
*/
191
185
public Image (Device device , int width , int height ) {
192
- this (device , width , height , DPIUtil .getNativeDeviceZoom ());
193
- }
194
-
195
-
196
- private Image (Device device , int width , int height , int nativeZoom ) {
197
186
super (device );
198
- this .initialNativeZoom = nativeZoom ;
199
187
this .imageProvider = new PlainImageProviderWrapper (width , height );
200
188
init ();
201
189
this .device .registerResourceWithZoomSupport (this );
@@ -243,7 +231,6 @@ public Image(Device device, Image srcImage, int flag) {
243
231
ImageHandle imageMetadata ;
244
232
if (srcImage == null ) SWT .error (SWT .ERROR_NULL_ARGUMENT );
245
233
if (srcImage .isDisposed ()) SWT .error (SWT .ERROR_INVALID_ARGUMENT );
246
- initialNativeZoom = srcImage .initialNativeZoom ;
247
234
this .type = srcImage .type ;
248
235
this .imageProvider = srcImage .imageProvider .createCopy (this );
249
236
this .styleFlag = srcImage .styleFlag | flag ;
@@ -352,7 +339,6 @@ public Image(Device device, Image srcImage, int flag) {
352
339
public Image (Device device , Rectangle bounds ) {
353
340
super (device );
354
341
if (bounds == null ) SWT .error (SWT .ERROR_NULL_ARGUMENT );
355
- initialNativeZoom = DPIUtil .getNativeDeviceZoom ();
356
342
this .imageProvider = new PlainImageProviderWrapper (bounds .width , bounds .height );
357
343
init ();
358
344
this .device .registerResourceWithZoomSupport (this );
@@ -384,7 +370,6 @@ public Image(Device device, Rectangle bounds) {
384
370
public Image (Device device , ImageData data ) {
385
371
super (device );
386
372
if (data == null ) SWT .error (SWT .ERROR_NULL_ARGUMENT );
387
- initialNativeZoom = DPIUtil .getNativeDeviceZoom ();
388
373
this .imageProvider = new PlainImageDataProviderWrapper (data );
389
374
init ();
390
375
this .device .registerResourceWithZoomSupport (this );
@@ -393,7 +378,6 @@ public Image(Device device, ImageData data) {
393
378
private Image (Device device , ImageData data , int zoom ) {
394
379
super (device );
395
380
if (data == null ) SWT .error (SWT .ERROR_NULL_ARGUMENT );
396
- initialNativeZoom = zoom ;
397
381
this .imageProvider = new PlainImageDataProviderWrapper (data , zoom );
398
382
init ();
399
383
this .device .registerResourceWithZoomSupport (this );
@@ -436,7 +420,6 @@ public Image(Device device, ImageData source, ImageData mask) {
436
420
if (source .width != mask .width || source .height != mask .height ) {
437
421
SWT .error (SWT .ERROR_INVALID_ARGUMENT );
438
422
}
439
- initialNativeZoom = DPIUtil .getNativeDeviceZoom ();
440
423
this .imageProvider = new MaskedImageDataProviderWrapper (source , mask );
441
424
init ();
442
425
this .device .registerResourceWithZoomSupport (this );
@@ -498,7 +481,6 @@ public Image(Device device, ImageData source, ImageData mask) {
498
481
public Image (Device device , InputStream stream ) {
499
482
super (device );
500
483
if (stream == null ) SWT .error (SWT .ERROR_NULL_ARGUMENT );
501
- initialNativeZoom = DPIUtil .getNativeDeviceZoom ();
502
484
this .imageProvider = new ImageDataLoaderStreamProviderWrapper (stream );
503
485
init ();
504
486
this .device .registerResourceWithZoomSupport (this );
@@ -539,7 +521,6 @@ public Image (Device device, InputStream stream) {
539
521
public Image (Device device , String filename ) {
540
522
super (device );
541
523
if (filename == null ) SWT .error (SWT .ERROR_NULL_ARGUMENT );
542
- initialNativeZoom = DPIUtil .getNativeDeviceZoom ();
543
524
this .imageProvider = new ImageFileNameProviderWrapper (zoom -> {
544
525
if (zoom == 100 ) {
545
526
return filename ;
@@ -582,7 +563,6 @@ public Image (Device device, String filename) {
582
563
public Image (Device device , ImageFileNameProvider imageFileNameProvider ) {
583
564
super (device );
584
565
this .imageProvider = new ImageFileNameProviderWrapper (imageFileNameProvider );
585
- initialNativeZoom = DPIUtil .getNativeDeviceZoom ();
586
566
if (imageFileNameProvider .getImagePath (100 ) == null ) {
587
567
SWT .error (SWT .ERROR_INVALID_ARGUMENT , null ,
588
568
": ImageFileNameProvider [" + imageFileNameProvider + "] returns null fileName at 100% zoom." );
@@ -623,7 +603,6 @@ public Image(Device device, ImageFileNameProvider imageFileNameProvider) {
623
603
public Image (Device device , ImageDataProvider imageDataProvider ) {
624
604
super (device );
625
605
this .imageProvider = new ImageDataProviderWrapper (imageDataProvider );
626
- initialNativeZoom = DPIUtil .getNativeDeviceZoom ();
627
606
if (imageDataProvider .getImageData (100 ) == null ) {
628
607
SWT .error (SWT .ERROR_INVALID_ARGUMENT , null ,
629
608
": ImageDataProvider [" + imageDataProvider + "] returns null ImageData at 100% zoom." );
@@ -653,7 +632,6 @@ public Image(Device device, ImageDataProvider imageDataProvider) {
653
632
public Image (Device device , ImageGcDrawer imageGcDrawer , int width , int height ) {
654
633
super (device );
655
634
this .imageProvider = new ImageGcDrawerWrapper (imageGcDrawer , width , height );
656
- initialNativeZoom = DPIUtil .getNativeDeviceZoom ();
657
635
init ();
658
636
}
659
637
@@ -848,10 +826,6 @@ public static void drawScaled(GC gc, Image original, int width, int height, floa
848
826
0 , 0 , Math .round (width * scaleFactor ), Math .round (height * scaleFactor ), false );
849
827
}
850
828
851
- long [] createGdipImage () {
852
- return createGdipImage (this .getZoom ());
853
- }
854
-
855
829
long [] createGdipImage (Integer zoom ) {
856
830
long handle = Image .win32_getHandle (this , zoom );
857
831
switch (type ) {
@@ -1035,9 +1009,7 @@ private void destroyHandles() {
1035
1009
1036
1010
@ Override
1037
1011
void destroyHandlesExcept (Set <Integer > zoomLevels ) {
1038
- destroyHandles (zoom -> {
1039
- return !zoomLevels .contains (zoom ) && zoom != DPIUtil .getZoomForAutoscaleProperty (initialNativeZoom );
1040
- });
1012
+ destroyHandles (zoom -> !zoomLevels .contains (zoom ));
1041
1013
}
1042
1014
1043
1015
private void destroyHandles (Predicate <Integer > filter ) {
@@ -1067,7 +1039,7 @@ public boolean equals (Object object) {
1067
1039
if (object == this ) return true ;
1068
1040
if (!(object instanceof Image )) return false ;
1069
1041
Image image = (Image ) object ;
1070
- if (device != image .device || transparentPixel != image .transparentPixel || getZoom () != image . getZoom () ) return false ;
1042
+ if (device != image .device || transparentPixel != image .transparentPixel ) return false ;
1071
1043
return (styleFlag == image .styleFlag ) && imageProvider .equals (image .imageProvider );
1072
1044
}
1073
1045
@@ -1833,9 +1805,6 @@ public void setBackground(Color color) {
1833
1805
zoomLevelToImageHandle .values ().forEach (imageHandle -> imageHandle .setBackground (backgroundColor ));
1834
1806
}
1835
1807
1836
- private int getZoom () {
1837
- return DPIUtil .getZoomForAutoscaleProperty (initialNativeZoom );
1838
- }
1839
1808
/**
1840
1809
* Returns a string containing a concise, human-readable
1841
1810
* description of the receiver.
@@ -2278,7 +2247,7 @@ protected ElementAtZoom<ImageData> loadImageData(int zoom) {
2278
2247
2279
2248
@ Override
2280
2249
public int hashCode () {
2281
- return Objects .hash (provider , styleFlag , transparentPixel , getZoom () );
2250
+ return Objects .hash (provider , styleFlag , transparentPixel );
2282
2251
}
2283
2252
2284
2253
@ Override
@@ -2521,7 +2490,6 @@ ImageData newImageData(int zoom) {
2521
2490
2522
2491
@ Override
2523
2492
protected ImageHandle newImageHandle (int zoom ) {
2524
- initialNativeZoom = zoom ;
2525
2493
int gcStyle = drawer .getGcStyle ();
2526
2494
Image image ;
2527
2495
if ((gcStyle & SWT .TRANSPARENT ) != 0 ) {
@@ -2532,7 +2500,7 @@ protected ImageHandle newImageHandle(int zoom) {
2532
2500
resultData .alphaData = new byte [scaledWidth * scaledHeight ];
2533
2501
image = new Image (device , resultData , zoom );
2534
2502
} else {
2535
- image = new Image (device , width , height , zoom );
2503
+ image = new Image (device , width , height );
2536
2504
}
2537
2505
GC gc = new GC (new DrawableWrapper (image , zoom ), gcStyle );
2538
2506
try {
0 commit comments