[libbluray-devel] Clip out of bounds image draw request

joakim git at videolan.org
Tue Feb 5 12:56:08 CET 2013


libbluray | branch: master | joakim <joakim at mefx.(none)> | Tue Feb  5 00:37:16 2013 +0100| [6cfbfb3f9c7f99624ed3b58f39d7ef2696cfee8e] | committer: hpi1

Clip out of bounds image draw request

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

 src/libbluray/bdj/java-j2me/java/awt/BDGraphics.java |   13 +++++++++++++
 src/libbluray/bdj/java-j2se/java/awt/BDGraphics.java |   13 +++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/src/libbluray/bdj/java-j2me/java/awt/BDGraphics.java b/src/libbluray/bdj/java-j2me/java/awt/BDGraphics.java
index 915f82d..b430fb5 100644
--- a/src/libbluray/bdj/java-j2me/java/awt/BDGraphics.java
+++ b/src/libbluray/bdj/java-j2me/java/awt/BDGraphics.java
@@ -613,6 +613,19 @@ class BDGraphics extends Graphics2D implements ConstrainableGraphics {
             if (!consumer.isComplete(observer))
                 return false;
         }
+
+        if(sx + sw > bdImage.width) {
+            int n = sx + sw - bdImage.width;
+            dw -= dw * n / sw;
+            sw -= n;
+        }
+
+        if(sy + sh > bdImage.height) {
+            int n = sy + sh - bdImage.height;
+            dh -= dh * n / sh;
+            sh -= n;
+        }
+
         if ((sw > 0) && (sh > 0) &&
             ((sx != 0) || (sy != 0) || (sw != bdImage.width) || (sh != bdImage.height))) {
             BDImage subImage = new BDImage(null, sw, sh, null);
diff --git a/src/libbluray/bdj/java-j2se/java/awt/BDGraphics.java b/src/libbluray/bdj/java-j2se/java/awt/BDGraphics.java
index 0be4bda..278dba1 100644
--- a/src/libbluray/bdj/java-j2se/java/awt/BDGraphics.java
+++ b/src/libbluray/bdj/java-j2se/java/awt/BDGraphics.java
@@ -690,6 +690,19 @@ class BDGraphics extends Graphics2D implements ConstrainableGraphics {
                 return false;
             }
         }
+
+        if(sx + sw > bdImage.width) {
+            int n = sx + sw - bdImage.width;
+            dw -= dw * n / sw;
+            sw -= n;
+        }
+
+        if(sy + sh > bdImage.height) {
+            int n = sy + sh - bdImage.height;
+            dh -= dh * n / sh;
+            sh -= n;
+        }
+
         if ((sw > 0) && (sh > 0) &&
             ((sx != 0) || (sy != 0) || (sw != bdImage.width) || (sh != bdImage.height))) {
             BDImage subImage = new BDImage(null, sw, sh, null);



More information about the libbluray-devel mailing list