@@ -1361,8 +1361,26 @@ export class Canvas implements ICanvas {
1361
1361
mWidth : number ;
1362
1362
mHeight : number ;
1363
1363
mScale = 1 ;
1364
+ mIsBitmap = false ;
1364
1365
view : WeakRef < CanvasView > ;
1365
1366
1367
+ constructor ( imageOrWidth : ImageSource | UIImage | number , height ?: number ) {
1368
+ let isBitmap = true ;
1369
+
1370
+ if ( imageOrWidth instanceof ImageSource ) {
1371
+ this . mCgContext = this . _createContextFromImage ( imageOrWidth . ios ) ;
1372
+ } else if ( imageOrWidth instanceof UIImage ) {
1373
+ this . mCgContext = this . _createContextFromImage ( imageOrWidth ) ;
1374
+ } else if ( imageOrWidth > 0 && height > 0 ) {
1375
+ this . mCgContext = this . _createContext ( imageOrWidth , height ) ;
1376
+ } else {
1377
+ isBitmap = false ;
1378
+ }
1379
+
1380
+ this . mIsBitmap = isBitmap ;
1381
+ // CGContextFillRect(this._cgContext);
1382
+ }
1383
+
1366
1384
setBitmap ( image ) {
1367
1385
// if (image instanceof ImageSource) {
1368
1386
// this._bitmap = image.android;
@@ -1454,7 +1472,7 @@ export class Canvas implements ICanvas {
1454
1472
setMatrix ( matrix : Matrix ) : void {
1455
1473
// TODO: Find a better way to implement matrix set
1456
1474
const ctx = this . ctx ;
1457
- const density = Screen . mainScreen . scale ;
1475
+ const density = this . mIsBitmap ? 1 : Screen . mainScreen . scale ;
1458
1476
const currentMatrix = this . getMatrix ( ) ;
1459
1477
const invertedTransform = CGAffineTransformInvert ( currentMatrix . mTransform ) ;
1460
1478
const scaleTransform = CGAffineTransformMake ( density , 0 , 0 , - density , 0 , density * this . mHeight ) ;
@@ -1765,16 +1783,6 @@ export class Canvas implements ICanvas {
1765
1783
getHeight ( ) {
1766
1784
return this . mHeight ;
1767
1785
}
1768
- constructor ( imageOrWidth : ImageSource | UIImage | number , height ?: number ) {
1769
- if ( imageOrWidth instanceof ImageSource ) {
1770
- this . mCgContext = this . _createContextFromImage ( imageOrWidth . ios ) ;
1771
- } else if ( imageOrWidth instanceof UIImage ) {
1772
- this . mCgContext = this . _createContextFromImage ( imageOrWidth ) ;
1773
- } else if ( imageOrWidth > 0 && height > 0 ) {
1774
- this . mCgContext = this . _createContext ( imageOrWidth , height ) ;
1775
- }
1776
- // CGContextFillRect(this._cgContext);
1777
- }
1778
1786
1779
1787
startApplyPaint ( paint ?: Paint , withFont = false ) {
1780
1788
this . save ( ) ;
0 commit comments