shadowislord 10 years ago
parent
commit
66d4763a04
1 changed files with 5 additions and 1 deletions
  1. 5 1
      jme3-desktop/src/main/java/com/jme3/util/Screenshots.java

+ 5 - 1
jme3-desktop/src/main/java/com/jme3/util/Screenshots.java

@@ -85,7 +85,11 @@ public final class Screenshots {
         int height = wr.getHeight();
 
         // flip the components the way AWT likes them
-        for (int y = 0; y < height / 2; y++){
+        
+        // calcuate half of height such that all rows of the array are written to
+        // e.g. for odd heights, write 1 more scanline
+        int heightdiv2ceil = height % 2 == 1 ? (height / 2) + 1 : height / 2;
+        for (int y = 0; y < heightdiv2ceil; y++){
             for (int x = 0; x < width; x++){
                 int inPtr  = (y * width + x) * 4;
                 int outPtr = ((height-y-1) * width + x) * 4;