@@ -789,10 +789,6 @@ private ImageHandle getImageMetadata(int zoom) {
789
789
return imageProvider .newImageHandle (zoom );
790
790
}
791
791
792
- private ImageHandle getImageMetadata (int targetWidth , int targetHeight ) {
793
- return this .imageProvider .newImageHandle (targetWidth , targetHeight );
794
- }
795
-
796
792
797
793
/**
798
794
* <b>IMPORTANT:</b> This method is not part of the public
@@ -820,11 +816,10 @@ public static long win32_getHandle (Image image, int zoom) {
820
816
/**
821
817
* @since 4.0
822
818
*/
823
- public static long win32_getHandle (Image image , int targetWidth , int targetHeight ) {
824
- if (image .isDisposed ()) {
825
- return 0L ;
826
- }
827
- return image .getImageMetadata (targetWidth , targetHeight ).handle ;
819
+ public void drawOnGCAtTargetSize (Consumer <Long > drawFunction , int targetWidth , int targetHeight ) {
820
+ ImageData imageData = this .imageProvider .newImageData (targetWidth , targetHeight );
821
+ long tempHandle = init (device , imageData ).handles ()[0 ];
822
+ drawFunction .accept (tempHandle );
828
823
}
829
824
830
825
/**
@@ -1625,12 +1620,6 @@ private ImageHandle initBitmapHandle(ImageData imageData, long handle, Integer z
1625
1620
return new ImageHandle (handle , zoom );
1626
1621
}
1627
1622
1628
- private ImageHandle initBitmapHandle (ImageData imageData , long handle , int targetWidth , int targetHeight ) {
1629
- type = SWT .BITMAP ;
1630
- transparentPixel = imageData .transparentPixel ;
1631
- return new ImageHandle (handle , targetWidth , targetHeight );
1632
- }
1633
-
1634
1623
static long [] initIcon (Device device , ImageData source , ImageData mask ) {
1635
1624
ImageData imageData = applyMask (source , mask );
1636
1625
return init (device , imageData ).handles ;
@@ -1727,23 +1716,6 @@ private ImageHandle init(ImageData i, int zoom) {
1727
1716
}
1728
1717
}
1729
1718
1730
- private ImageHandle init (ImageData i , int targetWidth , int targetHeight ) {
1731
- if (i == null ) SWT .error (SWT .ERROR_NULL_ARGUMENT );
1732
- HandleForImageDataContainer imageDataHandle = init (device , i );
1733
- switch (imageDataHandle .type ()) {
1734
- //TODO implement
1735
- // case SWT.ICON: {
1736
- // return initIconHandle(imageDataHandle.handles(), targetWidth, targetHeight);
1737
- // }
1738
- case SWT .BITMAP : {
1739
- return initBitmapHandle (imageDataHandle .imageData (), imageDataHandle .handles ()[0 ], targetWidth , targetHeight );
1740
- }
1741
- default :
1742
- SWT .error (SWT .ERROR_INVALID_ARGUMENT );
1743
- return null ;
1744
- }
1745
- }
1746
-
1747
1719
/**
1748
1720
* Invokes platform specific functionality to allocate a new GC handle.
1749
1721
* <p>
@@ -1970,11 +1942,6 @@ protected ImageHandle newImageHandle(int zoom) {
1970
1942
return newImageHandle (resizedData , zoom );
1971
1943
}
1972
1944
1973
- protected ImageHandle newImageHandle (int targetWidth , int targetHeight ) {
1974
- ImageData imageData = getImageData (targetWidth , targetHeight );
1975
- return init (imageData , targetWidth , targetHeight );
1976
- }
1977
-
1978
1945
protected final ImageHandle newImageHandle (ImageData data , int zoom ) {
1979
1946
if (type == SWT .ICON && data .getTransparencyType () != SWT .TRANSPARENCY_MASK ) {
1980
1947
// If the original type was an icon with transparency mask and re-scaling leads
@@ -2018,7 +1985,7 @@ ImageData newImageData(int zoom) {
2018
1985
2019
1986
@ Override
2020
1987
ImageData newImageData (int targetWidth , int targetHeight ) {
2021
- ImageData imageData = super . newImageHandle (targetWidth , targetHeight ). getImageData ( );
1988
+ ImageData imageData = getImageData (targetWidth , targetHeight );
2022
1989
return DPIUtil .autoScaleImageData (device , imageData , targetWidth , targetHeight );
2023
1990
}
2024
1991
@@ -2059,10 +2026,10 @@ ImageData newImageData(int zoom) {
2059
2026
2060
2027
@ Override
2061
2028
ImageData newImageData (int targetWidth , int targetHeight ) {
2062
- ImageHandle handle = initializeHandleFromSource (targetWidth , targetHeight );
2063
- ImageData data = handle . getImageData ( );
2064
- handle . destroy ( );
2065
- return data ;
2029
+ ElementAtTargetSize < ImageData > imageDataAtTargetSize = loadImageData (targetWidth , targetHeight );
2030
+ ImageData imageData = DPIUtil . autoScaleImageData ( device , imageDataAtTargetSize . element (), targetWidth , targetHeight );
2031
+ imageData = adaptImageDataIfDisabledOrGray ( imageData );
2032
+ return imageData ;
2066
2033
}
2067
2034
2068
2035
@ Override
@@ -2074,26 +2041,12 @@ protected ImageHandle newImageHandle(int zoom) {
2074
2041
return initializeHandleFromSource (zoom );
2075
2042
}
2076
2043
2077
- @ Override
2078
- protected ImageHandle newImageHandle (int targetWidth , int targetHeight ) {
2079
- return initializeHandleFromSource (targetWidth , targetHeight );
2080
- }
2081
-
2082
2044
private ImageHandle initializeHandleFromSource (int zoom ) {
2083
2045
ElementAtZoom <ImageData > imageDataAtZoom = loadImageData (zoom );
2084
2046
ImageData imageData = DPIUtil .scaleImageData (device , imageDataAtZoom .element (), zoom , imageDataAtZoom .zoom ());
2085
2047
imageData = adaptImageDataIfDisabledOrGray (imageData );
2086
2048
return newImageHandle (imageData , zoom );
2087
2049
}
2088
-
2089
- //TODO also handle IconHandle in addition to Bitmap
2090
- private ImageHandle initializeHandleFromSource (int targetWidth , int targetHeight ) {
2091
- ElementAtTargetSize <ImageData > imageDataAtTargetSize = loadImageData (targetWidth , targetHeight );
2092
- ImageData imageData = DPIUtil .autoScaleImageData (device , imageDataAtTargetSize .element (), targetWidth , targetHeight );
2093
- imageData = adaptImageDataIfDisabledOrGray (imageData );
2094
- return init (imageData , targetWidth , targetHeight );
2095
- }
2096
-
2097
2050
}
2098
2051
2099
2052
private class PlainImageDataProviderWrapper extends ImageFromImageDataProviderWrapper {
@@ -2252,8 +2205,7 @@ ImageData newImageData(int zoom) {
2252
2205
2253
2206
@ Override
2254
2207
ImageData newImageData (int targetWidth , int targetHeight ) {
2255
- ImageData imageData = super .newImageHandle (targetWidth , targetHeight ).getImageData ();
2256
- return DPIUtil .autoScaleImageData (device , imageData , targetWidth , targetHeight );
2208
+ return null ;
2257
2209
}
2258
2210
2259
2211
@ Override
@@ -2369,10 +2321,10 @@ ImageData newImageData(int zoom) {
2369
2321
2370
2322
@ Override
2371
2323
ImageData newImageData (int targetWidth , int targetHeight ) {
2372
- ImageHandle handle = initializeHandleFromSource (targetWidth , targetHeight );
2373
- ImageData data = handle . getImageData ( );
2374
- handle . destroy ( );
2375
- return data ;
2324
+ ElementAtTargetSize < ImageData > imageDataAtTargetSize = loadImageData (targetWidth , targetHeight );
2325
+ ImageData imageData = DPIUtil . autoScaleImageData ( device , imageDataAtTargetSize . element (), targetWidth , targetHeight );
2326
+ imageData = adaptImageDataIfDisabledOrGray ( imageData );
2327
+ return imageData ;
2376
2328
}
2377
2329
2378
2330
@ Override
@@ -2384,25 +2336,13 @@ protected ImageHandle newImageHandle(int zoom) {
2384
2336
return initializeHandleFromSource (zoom );
2385
2337
}
2386
2338
2387
- @ Override
2388
- protected ImageHandle newImageHandle (int targetWidth , int targetHeight ) {
2389
- return initializeHandleFromSource (targetWidth , targetHeight );
2390
- }
2391
-
2392
2339
private ImageHandle initializeHandleFromSource (int zoom ) {
2393
2340
ElementAtZoom <ImageData > imageDataAtZoom = loadImageData (zoom );
2394
2341
ImageData imageData = DPIUtil .scaleImageData (device ,imageDataAtZoom .element (), zoom , imageDataAtZoom .zoom ());
2395
2342
imageData = adaptImageDataIfDisabledOrGray (imageData );
2396
2343
return init (imageData , zoom );
2397
2344
}
2398
2345
2399
- private ImageHandle initializeHandleFromSource (int targetWidth , int targetHeight ) {
2400
- ElementAtTargetSize <ImageData > imageDataAtTargetSize = loadImageData (targetWidth , targetHeight );
2401
- ImageData imageData = DPIUtil .autoScaleImageData (device ,imageDataAtTargetSize .element (), targetWidth , targetHeight );
2402
- imageData = adaptImageDataIfDisabledOrGray (imageData );
2403
- return init (imageData , targetWidth , targetHeight );
2404
- }
2405
-
2406
2346
protected abstract ElementAtZoom <ImageData > loadImageData (int zoom );
2407
2347
2408
2348
protected abstract ElementAtTargetSize <ImageData > loadImageData (int targetWidth , int targetHeight );
@@ -2721,7 +2661,7 @@ ImageData newImageData(int zoom) {
2721
2661
2722
2662
@ Override
2723
2663
ImageData newImageData (int targetWidth , int targetHeight ) {
2724
- return getImageMetadata ( targetWidth , targetHeight ). getImageData () ;
2664
+ return null ;
2725
2665
}
2726
2666
2727
2667
@ Override
@@ -2752,12 +2692,6 @@ protected ImageHandle newImageHandle(int zoom) {
2752
2692
}
2753
2693
}
2754
2694
2755
- //TODO
2756
- @ Override
2757
- protected ImageHandle newImageHandle (int targetWidth , int targetHeight ) {
2758
- return null ;
2759
- }
2760
-
2761
2695
@ Override
2762
2696
Object getProvider () {
2763
2697
return drawer ;
@@ -2816,16 +2750,6 @@ public ImageHandle(long handle, int zoom) {
2816
2750
setImageMetadataForHandle (this , zoom );
2817
2751
}
2818
2752
2819
- public ImageHandle (long handle , int targetWidth , int targetHeight ) {
2820
- this .handle = handle ;
2821
- //TODO set right zoom here
2822
- this .zoom = 100 ;
2823
- updateBoundsInPixelsFromNative ();
2824
- if (backgroundColor != null ) {
2825
- setBackground (backgroundColor );
2826
- }
2827
- }
2828
-
2829
2753
public Rectangle getBounds () {
2830
2754
return new Rectangle (0 , 0 , width , height );
2831
2755
}
0 commit comments