Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Background Transparent for Android #87

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ project.xcworkspace
.idea
.gradle
local.properties
*.iml

# node.js
#
Expand Down
20 changes: 0 additions & 20 deletions android/android.iml

This file was deleted.

4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ android {

dependencies {
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.facebook.react:react-native:0.19.+'
}
compile 'com.facebook.react:react-native:+'
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

import android.content.Context;

import android.content.res.Resources;
import android.content.res.TypedArray;

import android.util.Log;
import android.view.View;
import android.view.MotionEvent;

Expand Down Expand Up @@ -86,23 +82,26 @@ public RSSignatureCaptureView(Context context, SignatureCallback callback) {
}

/**
* Get signature
*
* @return
* Get signature as a Bitmap
*/
public Bitmap getSignature() {
// Initialize a Bitmap to contain the signature
Bitmap signatureBitmap = Bitmap.createBitmap(this.getWidth(), this.getHeight(), Bitmap.Config.ARGB_8888);

Bitmap signatureBitmap = null;

// set the signature bitmap
if (signatureBitmap == null) {
signatureBitmap = Bitmap.createBitmap(this.getWidth(), this.getHeight(), Bitmap.Config.RGB_565);
}

// important for saving signature
// This view's pixels constitute the signature, so draw this view onto the signatureBitmap
final Canvas canvas = new Canvas(signatureBitmap);
this.draw(canvas);

// The signatureBitmap now contains the signature with a white background,
// so we will change it to a transparent background.
for (int x = 0; x < signatureBitmap.getWidth(); x++) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are two for loops. What about the performance of the component ? Did you do any performance test.

for (int y = 0; y < signatureBitmap.getHeight(); y++) {
if (Color.WHITE == signatureBitmap.getPixel(x, y)) {
signatureBitmap.setPixel(x, y, Color.TRANSPARENT);
}
}
}

return signatureBitmap;
}

Expand Down