Skip to content

Commit 933f0b1

Browse files
authored
Merge pull request #76 from BobHanson/hanson1
adds fix for JSGraphics2D.drawDirect (untested)
2 parents 4db990d + 110c38e commit 933f0b1

File tree

9 files changed

+22
-2
lines changed

9 files changed

+22
-2
lines changed
-65.7 KB
Binary file not shown.
-11 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20181213165944
1+
20181216002450
-65.7 KB
Binary file not shown.
-11 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20181213165944
1+
20181216002450
3.09 KB
Binary file not shown.

sources/net.sf.j2s.java.core/src/swingjs/JSGraphics2D.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,11 @@ private void drawDirect(int[] pixels, int x, int y, int width, int height, boole
546546
buf8[pt++] = argb & 0xFF;
547547
buf8[pt++] = (isRGB ? 0xFF : (argb >> 24) & 0xFF);
548548
}
549+
double[] m = HTML5CanvasContext2D.getMatrix(ctx, transform);
550+
if (m[0] != 1 || m[1] != 0 || m[2] != 0 || m[3] != 1)
551+
System.err.println("Unsupported transform");
552+
x += m[4];
553+
y += m[5];
549554
HTML5CanvasContext2D.putImageData(ctx, imageData, x, y);
550555
}
551556

sources/net.sf.j2s.java.core/src/swingjs/api/js/HTML5CanvasContext2D.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package swingjs.api.js;
22

3+
import java.awt.geom.AffineTransform;
4+
35
public abstract class HTML5CanvasContext2D {
46

57
public abstract void beginPath();
@@ -193,5 +195,18 @@ public static void setFillStyle(HTML5CanvasContext2D ctx, String s) {
193195
{}
194196
}
195197

198+
public static double[] getMatrix(HTML5CanvasContext2D ctx, AffineTransform transform) {
199+
double[] m = /** @j2sNative ctx._m || */ null;
200+
if (m == null) {
201+
m = new double[6];
202+
/**
203+
* @j2sNative
204+
* ctx._m = m;
205+
*/
206+
transform.getMatrix(m);
207+
}
208+
return m;
209+
}
210+
196211

197212
}

0 commit comments

Comments
 (0)