@@ -255,6 +255,18 @@ protected void calculatePageSize(Rectangle pageSize, float rotation, float zoom)
255
255
}
256
256
}
257
257
258
+ protected static double calculateScaleForDefaultScreen () {
259
+ try {
260
+ return GraphicsEnvironment .getLocalGraphicsEnvironment ()
261
+ .getDefaultScreenDevice () // could be an issue if multiple screens
262
+ .getDefaultConfiguration ()
263
+ .getDefaultTransform ()
264
+ .getScaleX ();
265
+ } catch (Exception e ) {
266
+ return 1.0 ;
267
+ }
268
+ }
269
+
258
270
@ Override
259
271
protected void paintComponent (Graphics g ) {
260
272
// create a copy, so we can set our own state without affecting the parent graphics content.
@@ -280,7 +292,8 @@ protected void paintComponent(Graphics g) {
280
292
// force one more paint to make sure we build a new buffer using the current zoom and rotation.
281
293
repaint ();
282
294
}
283
- g2d .drawImage (pageImage , paintingClip .x , paintingClip .y , null );
295
+ // will scale buffer to fit the current clip with smooths out any artifacts from screen scale factor
296
+ g2d .drawImage (pageImage , paintingClip .x , paintingClip .y , paintingClip .width , paintingClip .height , null );
284
297
}
285
298
g2d .dispose ();
286
299
}
@@ -410,18 +423,23 @@ public Object call() {
410
423
// paint page.
411
424
Page page = pageTree .getPage (pageIndex );
412
425
// page loading progress
413
- PageViewLoadingListener pageLoadingListener = new DefaultPageViewLoadingListener (parent , documentViewController );
426
+ PageViewLoadingListener pageLoadingListener = new DefaultPageViewLoadingListener (parent ,
427
+ documentViewController );
414
428
boolean isFirstProgressivePaint = false ;
415
429
try {
416
430
if (documentViewController != null ) page .addPageProcessingListener (pageLoadingListener );
417
431
// page init, interruptible
418
432
page .init ();
419
433
pageInitializedCallback (page );
420
434
435
+ double scale = AbstractPageViewComponent .calculateScaleForDefaultScreen ();
421
436
BufferedImage pageBufferImage = graphicsConfiguration .createCompatibleImage (
422
- imageLocation .width , imageLocation .height ,
437
+ (int ) (imageLocation .width * scale ),
438
+ (int ) (imageLocation .height * scale ),
423
439
BufferedImage .TYPE_INT_ARGB );
424
- Graphics g2d = pageBufferImage .createGraphics ();
440
+ Graphics2D g2d = pageBufferImage .createGraphics ();
441
+ g2d .scale (scale , scale );
442
+
425
443
426
444
// if we don't have a soft reference then we are likely on a first clean paint at which
427
445
// point we can kick off the animated paint.
0 commit comments