[libbluray-devel] BDJGraphics: sort coordinates in drawImage() to avoid passing negative widths and heights

Ian Curtis git at videolan.org
Tue Mar 18 20:07:37 CET 2014


libbluray | branch: master | Ian Curtis <i.curtis at gmail.com> | Tue Mar 18 21:02:12 2014 +0200| [3c472d27701422a736cc0c3acac0d4796f4f8537] | committer: hpi1

BDJGraphics: sort coordinates in drawImage() to avoid passing negative widths and heights

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=3c472d27701422a736cc0c3acac0d4796f4f8537
---

 .../bdj/java-j2me/java/awt/BDGraphics.java         |   27 ++++++++++++++++++--
 .../bdj/java-j2se/java/awt/BDGraphics.java         |   27 ++++++++++++++++++--
 2 files changed, 50 insertions(+), 4 deletions(-)

diff --git a/src/libbluray/bdj/java-j2me/java/awt/BDGraphics.java b/src/libbluray/bdj/java-j2me/java/awt/BDGraphics.java
index 87ad62e..0d678da 100644
--- a/src/libbluray/bdj/java-j2me/java/awt/BDGraphics.java
+++ b/src/libbluray/bdj/java-j2me/java/awt/BDGraphics.java
@@ -557,8 +557,31 @@ class BDGraphics extends Graphics2D implements ConstrainableGraphics {
         int dx1, int dy1, int dx2, int dy2,
         int sx1, int sy1, int sx2, int sy2,
         Color bg, ImageObserver observer) {
-        if ((dx1 >= dx2) || (dy1 >= dy2))
-            return false;
+
+        if (dx1 > dx2) {
+            int swap = dx1;
+            dx1 = dx2;
+            dx2 = swap;
+        }
+
+        if (dy1 > dy2) {
+            int swap = dy1;
+            dy1 = dy2;
+            dy2 = swap;
+        }
+
+        if (sx1 > sx2) {
+            int swap = sx1;
+            sx1 = sx2;
+            sx2 = swap;
+        }
+
+        if (sy1 > sy2) {
+            int swap = sy1;
+            sy1 = sy2;
+            sy2 = swap;
+        }
+
         return drawImageN(img, dx1, dy1, dx2 - dx1, dy2 - dy1,
                           sx1, sy1, sx2 - sx1, sy2 - sy1, bg, observer);
     }
diff --git a/src/libbluray/bdj/java-j2se/java/awt/BDGraphics.java b/src/libbluray/bdj/java-j2se/java/awt/BDGraphics.java
index 660acc9..6399da6 100644
--- a/src/libbluray/bdj/java-j2se/java/awt/BDGraphics.java
+++ b/src/libbluray/bdj/java-j2se/java/awt/BDGraphics.java
@@ -664,8 +664,31 @@ class BDGraphics extends Graphics2D implements ConstrainableGraphics {
         int dx1, int dy1, int dx2, int dy2,
         int sx1, int sy1, int sx2, int sy2,
         Color bg, ImageObserver observer) {
-        if ((dx1 >= dx2) || (dy1 >= dy2))
-            return false;
+
+        if (dx1 > dx2) {
+            int swap = dx1;
+            dx1 = dx2;
+            dx2 = swap;
+        }
+
+        if (dy1 > dy2) {
+            int swap = dy1;
+            dy1 = dy2;
+            dy2 = swap;
+        }
+
+        if (sx1 > sx2) {
+            int swap = sx1;
+            sx1 = sx2;
+            sx2 = swap;
+        }
+
+        if (sy1 > sy2) {
+            int swap = sy1;
+            sy1 = sy2;
+            sy2 = swap;
+        }
+
         return drawImageN(img, dx1, dy1, dx2 - dx1, dy2 - dy1,
                           sx1, sy1, sx2 - sx1, sy2 - sy1, bg, observer);
     }



More information about the libbluray-devel mailing list