@@ -2609,35 +2609,40 @@ static void buildDitheredGradientChannel(int from, int to, int steps,
2609
2609
* @param redBits the number of significant red bits, 0 for palette modes
2610
2610
* @param greenBits the number of significant green bits, 0 for palette modes
2611
2611
* @param blueBits the number of significant blue bits, 0 for palette modes
2612
+ * @param zoom the zoom of gc drawer used
2612
2613
*/
2613
- static void fillGradientRectangle (GC gc , Device device ,
2614
- int x , int y , int width , int height , boolean vertical ,
2615
- RGB fromRGB , RGB toRGB ,
2616
- int redBits , int greenBits , int blueBits ) {
2614
+ static void fillGradientRectangle (GC gc , Device device , int x , int y , int width , int height , boolean vertical ,
2615
+ RGB fromRGB , RGB toRGB , int redBits , int greenBits , int blueBits , int zoom ) {
2617
2616
/* Create the bitmap and tile it */
2618
- ImageData band = createGradientBand (width , height , vertical ,
2619
- fromRGB , toRGB , redBits , greenBits , blueBits );
2620
- Image image = new Image (device , band );
2617
+ ImageDataProvider imageDataProvider = imageZoom -> {
2618
+ float scaleFactor = imageZoom / 100.0f ;
2619
+ int scaledWidth = Math .round (width * scaleFactor );
2620
+ int scaledHeight = Math .round (height * scaleFactor );
2621
+ return createGradientBand (scaledWidth , scaledHeight , vertical , fromRGB , toRGB , redBits , greenBits ,
2622
+ blueBits );
2623
+ };
2624
+ Image image = new Image (device , imageDataProvider );
2625
+ ImageData band = image .getImageData ();
2621
2626
if ((band .width == 1 ) || (band .height == 1 )) {
2622
- gc .drawImage (image , 0 , 0 , DPIUtil .autoScaleDown (band .width ), DPIUtil .autoScaleDown (band .height ),
2623
- DPIUtil .autoScaleDown ( x ), DPIUtil .autoScaleDown ( y ), DPIUtil .autoScaleDown (width ),
2624
- DPIUtil .autoScaleDown (height ));
2627
+ gc .drawImage (image , 0 , 0 , DPIUtil .scaleDown (band .width , zoom ), DPIUtil .scaleDown (band .height , zoom ),
2628
+ DPIUtil .scaleDown ( x , zoom ), DPIUtil .scaleDown ( y , zoom ), DPIUtil .scaleDown (width , zoom ),
2629
+ DPIUtil .scaleDown (height , zoom ));
2625
2630
} else {
2626
2631
if (vertical ) {
2627
2632
for (int dx = 0 ; dx < width ; dx += band .width ) {
2628
2633
int blitWidth = width - dx ;
2629
2634
if (blitWidth > band .width ) blitWidth = band .width ;
2630
- gc .drawImage (image , 0 , 0 , DPIUtil .autoScaleDown (blitWidth ), DPIUtil .autoScaleDown (band .height ),
2631
- DPIUtil .autoScaleDown (dx + x ), DPIUtil .autoScaleDown ( y ), DPIUtil .autoScaleDown (blitWidth ),
2632
- DPIUtil .autoScaleDown (band .height ));
2635
+ gc .drawImage (image , 0 , 0 , DPIUtil .scaleDown (blitWidth , zoom ), DPIUtil .scaleDown (band .height , zoom ),
2636
+ DPIUtil .scaleDown (dx + x , zoom ), DPIUtil .scaleDown ( y , zoom ), DPIUtil .scaleDown (blitWidth , zoom ),
2637
+ DPIUtil .scaleDown (band .height , zoom ));
2633
2638
}
2634
2639
} else {
2635
2640
for (int dy = 0 ; dy < height ; dy += band .height ) {
2636
2641
int blitHeight = height - dy ;
2637
2642
if (blitHeight > band .height ) blitHeight = band .height ;
2638
- gc .drawImage (image , 0 , 0 , DPIUtil .autoScaleDown (band .width ), DPIUtil .autoScaleDown (blitHeight ),
2639
- DPIUtil .autoScaleDown ( x ), DPIUtil .autoScaleDown (dy + y ), DPIUtil .autoScaleDown (band .width ),
2640
- DPIUtil .autoScaleDown (blitHeight ));
2643
+ gc .drawImage (image , 0 , 0 , DPIUtil .scaleDown (band .width , zoom ), DPIUtil .scaleDown (blitHeight , zoom ),
2644
+ DPIUtil .scaleDown ( x , zoom ), DPIUtil .scaleDown (dy + y , zoom ), DPIUtil .scaleDown (band .width , zoom ),
2645
+ DPIUtil .scaleDown (blitHeight , zoom ));
2641
2646
}
2642
2647
}
2643
2648
}
0 commit comments