@@ -2609,35 +2609,40 @@ static void buildDitheredGradientChannel(int from, int to, int steps,
26092609 * @param redBits the number of significant red bits, 0 for palette modes
26102610 * @param greenBits the number of significant green bits, 0 for palette modes
26112611 * @param blueBits the number of significant blue bits, 0 for palette modes
2612+ * @param zoom the zoom of gc drawer used
26122613 */
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 ) {
26172616 /* 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 ();
26212626 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 ));
26252630 } else {
26262631 if (vertical ) {
26272632 for (int dx = 0 ; dx < width ; dx += band .width ) {
26282633 int blitWidth = width - dx ;
26292634 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 ));
26332638 }
26342639 } else {
26352640 for (int dy = 0 ; dy < height ; dy += band .height ) {
26362641 int blitHeight = height - dy ;
26372642 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 ));
26412646 }
26422647 }
26432648 }
0 commit comments