[libbluray-devel] BDGraphics: fix corruption when source image is smaller than source rect
hpi1
git at videolan.org
Wed Mar 26 00:10:49 CET 2014
libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Wed Mar 26 00:53:01 2014 +0200| [bf843d60d2445ac3fe9ba825424a8a13135b5f92] | committer: hpi1
BDGraphics: fix corruption when source image is smaller than source rect
> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=bf843d60d2445ac3fe9ba825424a8a13135b5f92
---
src/libbluray/bdj/java-j2me/java/awt/BDGraphics.java | 11 +++++++++++
src/libbluray/bdj/java-j2se/java/awt/BDGraphics.java | 11 +++++++++++
2 files changed, 22 insertions(+)
diff --git a/src/libbluray/bdj/java-j2me/java/awt/BDGraphics.java b/src/libbluray/bdj/java-j2me/java/awt/BDGraphics.java
index a21bc17..49f097a 100644
--- a/src/libbluray/bdj/java-j2me/java/awt/BDGraphics.java
+++ b/src/libbluray/bdj/java-j2me/java/awt/BDGraphics.java
@@ -992,6 +992,16 @@ class BDGraphics extends Graphics2D implements ConstrainableGraphics {
}
}
+ if(sx + sw > bdImage.width || sy + sh > bdImage.height) {
+ logger.info("drawImageN: fixing too small src image (src " + sx + "," + sy + " " + sw + "x" + sh + " ; img " + bdImage.width + "x" + bdImage.height + ")");
+
+ BDImage subImage = new BDImage(null, sw, sh, null);
+ bdImage.getRGB(sx, sy, Math.min(sw, bdImage.width - sx), Math.min(sh, bdImage.height - sy), subImage.getBdBackBuffer(), 0, sw);
+ bdImage = subImage;
+ sx = 0;
+ sy = 0;
+ }
+ /*
if(sx + sw > bdImage.width) {
int n = sx + sw - bdImage.width;
dw -= dw * n / sw;
@@ -1003,6 +1013,7 @@ class BDGraphics extends Graphics2D implements ConstrainableGraphics {
dh -= dh * n / sh;
sh -= n;
}
+ */
if ((sw > 0) && (sh > 0) &&
((sx != 0) || (sy != 0) || (sw != bdImage.width) || (sh != bdImage.height))) {
diff --git a/src/libbluray/bdj/java-j2se/java/awt/BDGraphics.java b/src/libbluray/bdj/java-j2se/java/awt/BDGraphics.java
index 4067ad1..0240e03 100644
--- a/src/libbluray/bdj/java-j2se/java/awt/BDGraphics.java
+++ b/src/libbluray/bdj/java-j2se/java/awt/BDGraphics.java
@@ -1099,6 +1099,16 @@ class BDGraphics extends Graphics2D implements ConstrainableGraphics {
}
}
+ if(sx + sw > bdImage.width || sy + sh > bdImage.height) {
+ logger.info("drawImageN: fixing too small src image (src " + sx + "," + sy + " " + sw + "x" + sh + " ; img " + bdImage.width + "x" + bdImage.height + ")");
+
+ BDImage subImage = new BDImage(null, sw, sh, null);
+ bdImage.getRGB(sx, sy, Math.min(sw, bdImage.width - sx), Math.min(sh, bdImage.height - sy), subImage.getBdBackBuffer(), 0, sw);
+ bdImage = subImage;
+ sx = 0;
+ sy = 0;
+ }
+ /*
if(sx + sw > bdImage.width) {
int n = sx + sw - bdImage.width;
dw -= dw * n / sw;
@@ -1110,6 +1120,7 @@ class BDGraphics extends Graphics2D implements ConstrainableGraphics {
dh -= dh * n / sh;
sh -= n;
}
+ */
if ((sw > 0) && (sh > 0) &&
((sx != 0) || (sy != 0) || (sw != bdImage.width) || (sh != bdImage.height))) {
More information about the libbluray-devel
mailing list