Skip to content

Commit

Permalink
api(images): images.copy(), Image(width, height)
Browse files Browse the repository at this point in the history
api(canvas): canvas.toImage(), Canvas(width, height)
  • Loading branch information
hyb1996 committed May 28, 2018
1 parent 30dbe6e commit 7cb7703
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,19 @@
public class ScriptCanvas {

private Canvas mCanvas;
private Bitmap mBitmap;

public ScriptCanvas(Canvas canvas) {
mCanvas = canvas;
public ScriptCanvas(int width, int height) {
this(Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888));
}

public ScriptCanvas(@NonNull Bitmap bitmap) {
mCanvas = new Canvas(bitmap);
mBitmap = bitmap;
}

public ScriptCanvas(@NonNull ImageWrapper image) {
this(image.getBitmap());
this(image.getBitmap().copy(image.getBitmap().getConfig(), true));
}

public ScriptCanvas() {
Expand All @@ -47,6 +49,10 @@ void setCanvas(Canvas canvas) {
mCanvas = canvas;
}

public ImageWrapper toImage() {
return ImageWrapper.ofBitmap(mBitmap.copy(mBitmap.getConfig(), true));
}

public boolean isHardwareAccelerated() {
return mCanvas.isHardwareAccelerated();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
/**
* Created by Stardust on 2017/11/25.
*/

public class ImageWrapper {

private Mat mMat;
Expand Down

0 comments on commit 7cb7703

Please sign in to comment.