< prev index next >

src/java.desktop/windows/native/libawt/windows/awt_Robot.cpp

Print this page

        

@@ -78,10 +78,17 @@
                 // value itself is now passed, cast as a PVOID so as to
                 // compile.  -bchristi 10/02/2001
                                      (PVOID)newSpeed,
                                      SPIF_SENDCHANGE);
 
+      int primaryIndex = AwtWin32GraphicsDevice::GetDefaultDeviceIndex();
+      Devices::InstanceAccess devices;
+      AwtWin32GraphicsDevice *device = devices->GetDevice(primaryIndex);
+
+      x = (device == NULL) ? x : device->ScaleUpX(x);
+      y = (device == NULL) ? y : device->ScaleUpY(y);
+
       POINT curPos;
       ::GetCursorPos(&curPos);
       x -= curPos.x;
       y -= curPos.y;
 

@@ -215,15 +222,28 @@
     int primaryIndex = AwtWin32GraphicsDevice::GetDefaultDeviceIndex();
     hOldPalette =
         AwtWin32GraphicsDevice::SelectPalette(hdcMem, primaryIndex);
     AwtWin32GraphicsDevice::RealizePalette(hdcMem, primaryIndex);
 
+    Devices::InstanceAccess devices;
+    AwtWin32GraphicsDevice *device = devices->GetDevice(primaryIndex);
+    int sWidth = (device == NULL) ? width : device->ScaleUpX(width);
+    int sHeight = (device == NULL) ? height : device->ScaleUpY(height);
+
     // copy screen image to offscreen bitmap
     // CAPTUREBLT flag is required to capture WS_EX_LAYERED windows' contents
     // correctly on Win2K/XP
+    if (width == sWidth && height == sHeight) {
     VERIFY(::BitBlt(hdcMem, 0, 0, width, height, hdcScreen, x, y,
-                                                SRCCOPY|CAPTUREBLT) != 0);
+               SRCCOPY | CAPTUREBLT) != 0);
+    } else {
+        int sX = (device == NULL) ? x : device->ScaleUpX(x);
+        int sY = (device == NULL) ? y : device->ScaleUpY(y);
+        VERIFY(::StretchBlt(hdcMem, 0, 0, width, height,
+               hdcScreen, sX, sY, sWidth, sHeight,
+               SRCCOPY | CAPTUREBLT) != 0);
+    }
 
     static const int BITS_PER_PIXEL = 32;
     static const int BYTES_PER_PIXEL = BITS_PER_PIXEL/8;
 
     if (!IS_SAFE_SIZE_MUL(width, height)) throw std::bad_alloc();
< prev index next >