gcacace / android-signaturepad Goto Github PK
View Code? Open in Web Editor NEWA custom Android View for drawing smooth signatures
License: Apache License 2.0
A custom Android View for drawing smooth signatures
License: Apache License 2.0
HI, I have a problem with your library, applicaiton crash on Motorolla Moto G phone.
It's work on nexus phone everytime.
But on moto G if I set fix size, it's work, but if I set match_parent, application crash :
11-30 10:41:54.441 18324-18324/temp.com.payzenmpos.dev E/AndroidRuntime: FATAL EXCEPTION: main
Process: temp.com.payzenmpos.dev, PID: 18324
java.lang.IllegalArgumentException: bitmap size exceeds 32bits
at android.graphics.Bitmap.nativeCreate(Native Method)
at android.graphics.Bitmap.createBitmap(Bitmap.java:836)
at android.graphics.Bitmap.createBitmap(Bitmap.java:813)
at android.graphics.Bitmap.createBitmap(Bitmap.java:780)
Do you have any idea ?
currently doing it this way:
public class SignaturePad extends com.github.gcacace.signaturepad.views.SignaturePad {
public SignaturePad(Context context, AttributeSet attrs) {
super(context, attrs);
}
public void setSignatureColorRes(int colorRes) {
try {
setSignatureColor(getResources().getColor(colorRes));
} catch (Resources.NotFoundException e) {
setSignatureColor(getResources().getColor(R.color.black));
}
}
public void setSignatureColor(int color) {
Field[] fields = getClass().getDeclaredFields();
for (Field field : fields) {
if ("mPaint".equals(field.getName())) {
field.setAccessible(true);
try {
field.set(this, color);
} catch (IllegalAccessException ignore) {
}
break;
}
}
}
}
My Signature view has 300dp height , In my finger or palm touch out side on my Signature view , the touch event not working
Hello, is it possible to add the support for different bitmap configs?
I'd like to reduce an image size as much as i can by applying ALPHA_8
, but as i see the library works only with ARGB_8888
.
We got a OutOfMemoryException crash report from out production app. First time it's ever happened, but I thought I'd log it anyway in the hopes that you can improve your library :)
Device: Samsung Galaxy Note 10.1 2014 Edition (SM-P605)
OS Version: Android 4.4.2
Stack Trace:
java.lang.OutOfMemoryError
at android.graphics.Bitmap.nativeCreate(Native Method)
at android.graphics.Bitmap.createBitmap(Bitmap.java:924)
at android.graphics.Bitmap.createBitmap(Bitmap.java:901)
at android.graphics.Bitmap.createBitmap(Bitmap.java:868)
at com.github.gcacace.signaturepad.views.SignaturePad.ensureSignatureBitmap(SignaturePad.java:471)
at com.github.gcacace.signaturepad.views.SignaturePad.addBezier(SignaturePad.java:363)
at com.github.gcacace.signaturepad.views.SignaturePad.addPoint(SignaturePad.java:351)
at com.github.gcacace.signaturepad.views.SignaturePad.onTouchEvent(SignaturePad.java:159)
at android.view.View.dispatchTouchEvent(View.java:8045)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2423)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2156)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2423)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2156)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2423)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2156)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2423)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2156)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2423)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2156)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2423)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2156)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2423)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2156)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2423)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2156)
at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2295)
at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1622)
at android.app.Dialog.dispatchTouchEvent(Dialog.java:761)
at android.support.v7.internal.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:59)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2243)
at android.view.View.dispatchPointerEvent(View.java:8240)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4654)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4520)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4078)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4132)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4101)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4212)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4109)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4269)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4078)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4132)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4101)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4109)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4078)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6437)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6354)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6325)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6290)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6517)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method)
at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:176)
at android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:6490)
at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:6536)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:803)
at android.view.Choreographer.doCallbacks(Choreographer.java:603)
at android.view.Choreographer.doFrame(Choreographer.java:571)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:789)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5476)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
at dalvik.system.NativeStart.main(Native Method)
It would be awesome to have gradle support for easily integration of this library into any project.
I'm trying to open the project in Android Studio - I'm getting the following messages:
C:\Users\JIMB\AndroidStudioProjects\android-signaturepad\signature-pad\build.gradle
Error:(10, 0) C:\Users\JIMB\AndroidStudioProjects\android-signaturepad\bintray.properties (The system cannot find the file specified)
Any ideas?
Hi,
I tried to use your library, but doesn't work properly on my Samsumg Note 3, the scroll of the ScrollView
does not work.
You know why you can be? Can you help me, please?
Thanks for your library :)
Currently there are no unit tests for the library.
First, many thanks for this awesome library.
I have a quick question regarding the upload of the Bitmap Signature on a server.
When calling the getSignatureBitmap() and receiving the Bitmap:
Thanks a lot in advance for your assistance,
Isabelle,
If you call getSignatureSvg() multiple times upon created signature, it's adding last SVG path again and again.
Hello, the code written really good, I was used in Android TV at the same time more than one signature, what should I do?
Is it possible to export an .svg of the signature? or is bitmap only possible with this library?
If it is possible, please add documentation for it. If not, please add it!
Thanks!
Im sorry for open an Issue to do this, but i dont really know how GitHub works :D
This is a suggestion to put in getTransparentSignatureBitmap() method:
public static Bitmap TrimImage(Bitmap bmp) {
int imgHeight = bmp.getHeight();
int imgWidth = bmp.getWidth();
//TRIM WIDTH
int width = 0;
for(int i = 0; i < imgHeight; i++) {
for(int j = imgWidth - 1; j >= 0; j--) {
if(bmp.getPixel(j, i) != Color.TRANSPARENT &&
j > width) {
width = j;
break;
}
}
}
//TRIM HEIGHT
int height = 0;
for(int i = 0; i < imgWidth; i++) {
for(int j = imgHeight - 1; j >= 0; j--) {
if(bmp.getPixel(i, j) != Color.TRANSPARENT &&
j > height) {
height = j;
break;
}
}
}
return Bitmap.createBitmap(bmp, 0,0,width, height);
}
This will get just the Signature image, not returning the white/transparent space. A better result for the method
Hope it helps someone
I think variable "steps","length" should be declared with type "float",right?
Is it possible to get bio metric data from the signature?
spatial coordinate x(t)
spatial coordinate y(t)
pressure p(t)
azimuth az(t)
inclination in(t)
pen up/down
Signature pen color is not set after calling a method
mSignaturePad.setPenColorRes(color);//where color is get by Color Picker Dialog.
The moment you life your finger the saveSignature function is called. The saveSignature function never fires again unless a clear is called. As a result, any signatures that require lifting the finger, do not render anything after the life when saved.
Can the touch fire save after every finger lift or after a delay (i.e. if the finger does not touch the screen in x seconds, then save)
change this:
compile 'com.github.gcacace:android-signaturepad:1.0.0'
to this
compile 'com.github.gcacace:signature-pad:1.0.0'
Would be nice if we had the option to Save the bitmap with the specified background instead of just a bitmap of the signature.
1.1.0 doesn't contain clearOnDoubleClick
I need to remove a specific area . Not the entire area.
So i tried changing pen color with transparent, but it clear a rect area.
I just need to remove specific line.
Please tell me how to do it.
Hi,
I do not know to use the library in my project, would you please give me some help?
Thanks
When we just touch the signaturepad and have not drawn our signature, onSigned callback gets executed.
I need to be able to save the signature as a bitmap within the app and then apply it as a texture for a 3d plane. Can I do that without saving it to the storage on the device? In the same way you would do text to bitmap?
Hello, is it possible to add SignaturePadBindingAdapter for support android data binding?
Unable to Store Signature and Unable to store svg signature these two messages are populating when I am trying to save the image.
Created image file .JPG along with it Directory but throws an error:
E/SignaturePad: Directory not created
E/SignaturePad: Directory not created
Should fix this? or just ignore?
When SignaturePad is used inside a scroll view or ViewPager, the touch event is not blocked to prevent propagation.
I am using your lib to capture signatures. It works for all devices that I have except the note4. It gives error when I am trying to open it on my phone after I compress it on a png format.
Only have this problem on the note4. any compression/decompression on it is failing.
The file that gets created is : https://www.dropbox.com/s/r83eha2wrjikdqs/signature?dl=0
On nexus the file that gets created with same codebase is: https://www.dropbox.com/s/wmm6xtg3lo7xsqq/signature-2?dl=0
Please advise as I am stuck.
hi, I want to to use the svg file to save it on my project, so I draw the signature on android like this
then i saved it and check the jpeg file, it shows the same picture like this
but when i check the svg file, I open it on AI, it shows like this
yes it shows the same picture like the original, but there are some unwanted line from the up-left corner of the picture
can anyone help me? :)
Hello,
I'm using signature pad with screen rotation, so I use getTransparentSignatureBitmap and setSignatureBitmap and each time the screen rotate it removes a pixel line.
To fixe this I change the return line of getTransparentSignatureBitmap:
return Bitmap.createBitmap(mSignatureBitmap, xMin, yMin, xMax - xMin, yMax - yMin);
into
return Bitmap.createBitmap(
mSignatureBitmap,
xMin > 0 ? xMin - 1 : 0,
yMin > 0 ? yMin - 1 : 0,
xMax < imgWidth ? (xMax - xMin + 2): (xMax - xMin),
yMax < imgHeight ? (yMax - yMin + 2): (yMax - yMin));
Best regards,
I just noticed an issue with the SVG generated by 1.2.0 that I could not replicate with 1.1.0 - it seems to connect on its own to the top left corner, see the two SVG / emulator screenshots with the different versions. The signature is a simple series of loops starting from somewhere in the top left corner.
(PS: It appears there is a difference in default line thinkness between the two versions, I can raise that as a different issue, I left it with defaults just in case it might be relevant somehow).
Comparing v1.1.0...v1.2.0 I see there are quite a few SVG related changes mostly done by @thomasleveil, copying him for thoughts on this.
Tested with Visual Studio Emulator for Android
4.5", xhdpi, Android 5.1.1 (similar to Motorola Moto G, Motorola Moto X)
When i save the signature bitmap as a file to storage,the local file is changed black ,can't see the signature content
Hi i have a requirement, i need to set the already signed signature bit to the signature view, and allow user to edit or modify the signature. I couldnt do this with this library. Except this , the library is working awesome. Please provide a solution. Thanks in advance.
my email is [email protected]. Its urgent for me. If you help me to find a solution, it will help a lot.
how to add stamp in my signature,
i create an purchase order application,
how to add my PO number in my signature.
ex PO01/12/13
my po number in top right of my signature
need help
After using the clearOnDoubleClick feature, the pad is not empty (isEmpty() == false).
I want to use the OnSignedListener to toggle a button state but onSigned is always called after the double click gesture.
If you look at this line, you can see that something is drawn after MotionEvent.ACTION_UP events preventing the pad to be cleared properly.
Based on how I have to save and load the SVG I'm dealing with, it'd be really helpful if there was a conversion from SVG back into the canvas. This would, in a lot of cases I think, greatly shrink the storage requirements for the signatures.
I've tried several different methods of converting the Bitmap to string, converting the saved SVG into a bitmap, and compressing the bitmap. But my bitmaps are coming out > 9MB. I would store them on the device, but then I have to add code to manage that over time.
Does anyone have any ideas on best way to manage this data? By and large my data is being stored in a SqlLite via SugarOrm, and it balks on large fields. It seems crazy to store the data in a bitmap when the SVG is so much more concise.
Calling setSignatureBitmap() on onCreate() of an Activity will result in a crash, because getWidth() and getHeight() of SignaturePad are null.
def supportLibraryVersion = '23.2.1'
compile "com.android.support:preference-v7:$supportLibraryVersion"
compile "com.android.support:preference-v14:$supportLibraryVersion"
compile "com.github.gcacace:signature-pad:1.1.0@aar"
Error on build: Error:(187) Attribute "maxWidth" has already been defined
if the user only signs a small part in the middle of the screen, the image is a lot bigger than that - is it possible to get the signature part only?
When trying to start the activity with this view in it:
`
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="@android:color/darker_gray"
android:layout_marginBottom="8dp"
android:layout_above="@+id/signature_pad_description" />
<TextView
android:id="@+id/signature_pad_description"
android:layout_width="wrap_content"
android:layout_centerHorizontal="true"
android:layout_height="wrap_content"
android:textColor="@android:color/darker_gray"
android:layout_marginBottom="16dp"
android:layout_alignParentBottom="true"
android:text="@string/agreementR" />
<com.github.gcacace.signaturepad.views.SignaturePad
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/signature_pad"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:penColor="@android:color/black"
/>
</RelativeLayout>`
I get this error:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.portalcarriers.portal/com.portalcarriers.portal.SignActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.github.gcacace.signaturepad.views.SignaturePad.setOnSignedListener(com.github.gcacace.signaturepad.views.SignaturePad$OnSignedListener)' on a null object reference at ... com.portalcarriers.portal.SignActivity.onCreate(SignActivity.java:41) at ...ย
Here's the onCreate for the activity:
`@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_scan);
this.extras = getIntent().getExtras();
this.type = this.extras.getInt("type");
TextView agreement = (TextView) findViewById(R.id.signature_pad_description);
if(type == 1){
agreement.setText(R.string.agreementR);
}
else if(type == 2){
agreement.setText(R.string.agreementD);
}
mSignaturePad = (SignaturePad) findViewById(R.id.signature_pad);
//LINE 41-----mSignaturePad.setOnSignedListener(new SignaturePad.OnSignedListener() {
@Override
public void onStartSigning() {
}
@Override
public void onSigned() {
mSaveButton.setEnabled(true);
mClearButton.setEnabled(true);
}
@Override
public void onClear() {
mSaveButton.setEnabled(false);
mClearButton.setEnabled(false);
}
});
mClearButton = (Button) findViewById(R.id.clear_button);
mSaveButton = (Button) findViewById(R.id.save_button);
mClearButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mSignaturePad.clear();
}
});
mSaveButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Bitmap signatureBitmap = mSignaturePad.getTransparentSignatureBitmap();
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
signatureBitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);
byte[] byteArray = byteArrayOutputStream .toByteArray();
String encoded = Base64.encodeToString(byteArray, Base64.DEFAULT);
Intent returnIntent = new Intent();
returnIntent.putExtra("img", encoded);
setResult(Activity.RESULT_OK, returnIntent);
finish();
}
});
}`
What to do when the view size changes? The signature should be cropped or shrinked?
It would be great to set the pen size in dp, instead of px.
When we tap clear, we do clear the data, but to the user the UI does not reflect that.
@OverRide
public void onSigned() {
Bitmap signatureBitmap = mSignaturePad.getTransparentSignatureBitmap();
This bitmap shows a very small signature
Tapping on the SignaturePad to draw dots doesn't render the zero length line.
no matter what I set for orientation in the AndroidManifest.xml, the orientation is always locked to one specific landscape, is it possible to use it in both?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.