@@ -147,8 +147,6 @@ protected void allocate() {
147
147
bitmap = Bitmap .createBitmap (width , height , Config .ARGB_8888 );
148
148
canvas = new Canvas (bitmap );
149
149
}
150
- // image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
151
- // canvas = (Graphics2D) image.getGraphics();
152
150
}
153
151
154
152
@@ -458,7 +456,8 @@ public void breakShape() {
458
456
@ Override
459
457
public void endShape (int mode ) {
460
458
if (shape == POINTS && stroke && vertexCount > 0 ) {
461
- Matrix m = canvas .getMatrix ();
459
+ // Matrix m = canvas.getMatrix();
460
+ Matrix m = getMatrixImp ();
462
461
if (strokeWeight == 1 && m .isIdentity ()) {
463
462
if (screenPoint == null ) {
464
463
screenPoint = new float [2 ];
@@ -1527,8 +1526,9 @@ public PMatrix2D getMatrix(PMatrix2D target) {
1527
1526
target = new PMatrix2D ();
1528
1527
}
1529
1528
// canvas.getTransform().getMatrix(transform);
1530
- Matrix m = new Matrix ();
1531
- canvas .getMatrix (m );
1529
+ // Matrix m = new Matrix();
1530
+ // canvas.getMatrix(m);
1531
+ Matrix m = getMatrixImp ();
1532
1532
m .getValues (transform );
1533
1533
// target.set((float) transform[0], (float) transform[2], (float) transform[4],
1534
1534
// (float) transform[1], (float) transform[3], (float) transform[5]);
@@ -1575,6 +1575,12 @@ public void printMatrix() {
1575
1575
}
1576
1576
1577
1577
1578
+ protected Matrix getMatrixImp () {
1579
+ return parent .getSurfaceView ().getMatrix ();
1580
+ // return canvas.getMatrix();
1581
+ }
1582
+
1583
+
1578
1584
1579
1585
//////////////////////////////////////////////////////////////
1580
1586
@@ -1619,7 +1625,8 @@ public float screenX(float x, float y) {
1619
1625
}
1620
1626
screenPoint [0 ] = x ;
1621
1627
screenPoint [1 ] = y ;
1622
- canvas .getMatrix ().mapPoints (screenPoint );
1628
+ // canvas.getMatrix().mapPoints(screenPoint);
1629
+ getMatrixImp ().mapPoints (screenPoint );
1623
1630
return screenPoint [0 ];
1624
1631
}
1625
1632
@@ -1633,7 +1640,8 @@ public float screenY(float x, float y) {
1633
1640
}
1634
1641
screenPoint [0 ] = x ;
1635
1642
screenPoint [1 ] = y ;
1636
- canvas .getMatrix ().mapPoints (screenPoint );
1643
+ // canvas.getMatrix().mapPoints(screenPoint);
1644
+ getMatrixImp ().mapPoints (screenPoint );
1637
1645
return screenPoint [1 ];
1638
1646
}
1639
1647
@@ -2060,35 +2068,28 @@ public void set(int x, int y, PImage src) {
2060
2068
}
2061
2069
2062
2070
if (src .bitmap == null ) {
2063
- // hopefully this will do the work to figure out what's on/offscreen
2064
- // in spite of the offset and stride that's been provided
2065
- canvas . drawBitmap ( src . pixels , 0 , src . width ,
2066
- x , y , src .width , src .height , false , null );
2067
- // hasAlpha is set to false since we don't want blending.
2068
- // however that may be incorrect if it winds up copying only the RGB
2069
- // (without the A) portion of the pixels.
2070
-
2071
- } else { // src.bitmap != null
2072
- if (src .width != src . bitmap . getWidth () ||
2073
- src . height != src .bitmap .getHeight ()) {
2071
+ src . bitmap = Bitmap . createBitmap ( src . width , src . height , Config . ARGB_8888 );
2072
+ src . modified = true ;
2073
+ }
2074
+ if ( src .width != src .bitmap . getWidth () ||
2075
+ src . height != src . bitmap . getHeight ()) {
2076
+ src . bitmap . recycle ();
2077
+ src . bitmap = Bitmap . createBitmap ( src . width , src . height , Config . ARGB_8888 );
2078
+ src . modified = true ;
2079
+ }
2080
+ if (src .modified ) {
2081
+ if (! src .bitmap .isMutable ()) {
2074
2082
src .bitmap .recycle ();
2075
2083
src .bitmap = Bitmap .createBitmap (src .width , src .height , Config .ARGB_8888 );
2076
- src .modified = true ;
2077
2084
}
2078
- if (src .modified ) {
2079
- if (!src .bitmap .isMutable ()) {
2080
- src .bitmap .recycle ();
2081
- src .bitmap = Bitmap .createBitmap (src .width , src .height , Config .ARGB_8888 );
2082
- }
2083
- src .bitmap .setPixels (src .pixels , 0 , src .width , 0 , 0 , src .width , src .height );
2084
- src .modified = false ;
2085
- }
2086
- // set() happens in screen coordinates, so need to clear the ctm
2087
- canvas .save (Canvas .MATRIX_SAVE_FLAG );
2088
- canvas .setMatrix (null ); // set to identity
2089
- canvas .drawBitmap (src .bitmap , x , y , null );
2090
- canvas .restore ();
2085
+ src .bitmap .setPixels (src .pixels , 0 , src .width , 0 , 0 , src .width , src .height );
2086
+ src .modified = false ;
2091
2087
}
2088
+ // set() happens in screen coordinates, so need to clear the ctm
2089
+ canvas .save (Canvas .MATRIX_SAVE_FLAG );
2090
+ canvas .setMatrix (null ); // set to identity
2091
+ canvas .drawBitmap (src .bitmap , x , y , null );
2092
+ canvas .restore ();
2092
2093
}
2093
2094
2094
2095
0 commit comments