Giter VIP home page Giter VIP logo

ink-android's People

Contributors

markchous avatar nak5ive avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ink-android's Issues

Cannot get bitmap with transparent background

Hi guys. First of all thanks for a great library. Its responsive brush is really cool. And its really easy to get the bitmap. However, I am having a problem when I get the bitmap with transparent background. Instead of getting transparent background, I am getting black background. Please help me in this.

Crash: width and height must be > 0 (v0.2.1)

Every so often I'll get this crash from prod in one of my apps:

java.lang.IllegalArgumentException: width and height must be > 0
    at android.graphics.Bitmap.createBitmap(Bitmap.java:939)
    at android.graphics.Bitmap.createBitmap(Bitmap.java:918)
    at android.graphics.Bitmap.createBitmap(Bitmap.java:885)
    at com.simplify.ink.InkView.clear(InkView.java:377)
    at com.simplify.ink.InkView.onSizeChanged(InkView.java:160)
    at android.view.View.sizeChange(View.java:16876)
    at android.view.View.setFrame(View.java:16849)
    at android.view.View.layout(View.java:16764)
    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573)
    at android.widget.FrameLayout.onLayout(FrameLayout.java:508)
     ...

The stack trace is pretty straight forward to follow. The exception appears to be occurring during a layout pass. I'm not doing anything crazy - the InkView is defined in an XML layout. It actually has a specified height (199dp) so it's the width that must be 0 (match parent).

I'm not sure what the circumstances of this are; maybe the activity is being minimised as a layout pass is occuring?

A fix may be to simply wrap bitmap creation with a size check.

edit: While you're there...
mDebugBitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888);
This line almost doubles the memory footprint of the view; it should probably only be instantiated when debug is enabled.

'xdpi' and 'ydpi'

DisplayMetrics metrics = getContext().getResources().getDisplayMetrics();
mDensity = (metrics.xdpi + metrics.ydpi) / 2f;
Could you tell me are 'xdpi' and 'ydpi' in these two pieces of code equal to the width and the height in ios? Thank you.

Slight performance boost

The following gives a slight performance increase on low end devices as it only invalidates the drawn rect.

Just call in your draw method

 invalidateRec(p1, p2);
private void invalidateRec(InkPoint p1, InkPoint p2 ) {

        final int xMin = (int) Math.floor(Math.min(p1.x, p2.x));
        final int xMax = (int) Math.ceil(Math.max(p1.x, p2.x));

        final int yMin = (int) Math.floor(Math.min(p1.y, p2.y));
        final int yMax = (int) Math.ceil(Math.max(p1.y, p2.y));

        invalidate(xMin, yMin, xMax, yMax);
    }

TBH it's made tesing on an emulator possible for me.

edit: far less verbose

Unable to change color of stroke with setColor()

I am trying to change the color of the ink but mInkView.setColor() has no effect. I'm not using any flags or anything. in xml it looks like this

<com.simplify.ink.InkView
android:id="@+id/ink"
android:layout_width="match_parent"
android:layout_height="match_parent"/>

and then in fragment

mInkView = (InkView) view.findViewById(R.id.ink);
mInkView .setColor(getResources().getColor(R.color.colorAccent));
mInkView .setMinStrokeWidth(1.5f);
mInkView .setMaxStrokeWidth(6f);

Thanks

Undo draw?

Is there an option/flag to enable undos?

Out of Memory exception

Hi, you wrote a really nice library for drawing or signature. I have an issue. Sometimes I get OutOfMemory Exception when I clear my drawing and new bitmap is created.

java.lang.OutOfMemoryError
at android.graphics.Bitmap.nativeCreate(Native Method)
at android.graphics.Bitmap.createBitmap(Bitmap.java:822)
at android.graphics.Bitmap.createBitmap(Bitmap.java:799)
at android.graphics.Bitmap.createBitmap(Bitmap.java:766)
at com.bolo.customview.InkView.clear(InkView.java:385)
at com.demo.FragmentDemoDraw.clearDrawing(FragmentDemoDraw.java:108)

I am getting this exception in below line.

mDebugBitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888);

How can I prevent it? Please help me out.

Firebase Crashlytics width and height must be > 0 v1.0.1

I am receiving following crash report in Firebase Crashlytics

Caused by java.lang.IllegalArgumentException: width and height must be > 0 at android.graphics.Bitmap.createBitmap(Bitmap.java:877) at android.graphics.Bitmap.createBitmap(Bitmap.java:856) at android.graphics.Bitmap.createBitmap(Bitmap.java:823) at com.simplify.ink.InkView.clear(InkView.java:382) at myapp.MapsActivity.drawTapped(MapsActivity.java:3702) at java.lang.reflect.Method.invoke(Method.java) at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:385) at android.view.View.performClick(View.java:5623) at android.view.View$PerformClick.run(View.java:22433) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6316) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)

This is happening for very small percentage of users. My app can change orientation. Any idea on why this might be happening?

Out of Memory Exception

Hi,

I love your SignaturePad. It is the most fluent method getting signatures on a phone.

Unfortunately I am getting a really strange problem. Look here is the Crash which Airbrake is telling me:

VMRuntime.java:-2 in dalvik.system.VMRuntime.newNonMovableArray
Bitmap.java:-2 in android.graphics.Bitmap.nativeCreate
Bitmap.java:817 in android.graphics.Bitmap.createBitmap
Bitmap.java:794 in android.graphics.Bitmap.createBitmap
Bitmap.java:761 in android.graphics.Bitmap.createBitmap
InkView.java:377 in com.simplify.ink.InkView.clear
InkView.java:160 in com.simplify.ink.InkView.onSizeChanged
View.java:15746 in android.view.View.sizeChange
View.java:15719 in android.view.View.setFrame
View.java:15626 in android.view.View.layout
LinearLayout.java:1705 in android.widget.LinearLayout.setChildFrame
LinearLayout.java:1559 in android.widget.LinearLayout.layoutVertical
LinearLayout.java:1468 in android.widget.LinearLayout.onLayout
View.java:15631 in android.view.View.layout
ViewGroup.java:4966 in android.view.ViewGroup.layout

I don't know if there is a problem with the SignaturePad or my code for saving the signature to the sqlite database. We started our project in October 2015 with Nexus 6 devices, this error didn't happen to the begging. Just after realizing our app for the other company phones like LG G3 we getting more and more problem with the Memory Exception. In the android manifest I added the line: android:largeHeap="true" but the same error appears.

Could you please check if there is a problem with my code?

` private InkView ink;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.signaturepad);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

    ink = (InkView) findViewById(R.id.ink);
    ink.setColor(getResources().getColor(android.R.color.black));
    ink.setMinStrokeWidth(1.5f);
    ink.setMaxStrokeWidth(6f);
    ink.setFlags(InkView.FLAG_INTERPOLATION | InkView.FLAG_RESPONSIVE_WIDTH);
}

@Override
public void onBackPressed() {
    super.onBackPressed();
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_signaturepad, menu);
    return super.onCreateOptionsMenu(menu);
}


@Override
public boolean onOptionsItemSelected(MenuItem item) {

    int id = item.getItemId();

    if (id == R.id.signaturesafe) {

        try {

            String encodedImage = "";
            Bitmap a = ink.getBitmap(getResources().getColor(R.color.trans));
            a = this.getResizedBitmap(a, 306, 912);
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            a.compress(Bitmap.CompressFormat.PNG, 10, baos); //bm is the bitmap object
            byte[] b = baos.toByteArray();
            encodedImage = Base64.encodeToString(b, Base64.DEFAULT);

          // INSERT BASE64 Signature into Local Database
            for (int i = 0; i < Globals.GlobalOrderHeaderListToObjekt.size(); i++) {
                mySQLHelper1.fillinSignatureAndName(encodedImage, NameInKlarschrift, Globals.GlobalOrderHeaderListToObjekt.get(i), false);
            }

            mySQLHelper1.close();

            a.recycle();
            encodedImage = "";

        }catch (Exception e)
        {
            AirbrakeNotifier.notify(e);
        }

    }
    return super.onOptionsItemSelected(item);
}

public Bitmap getResizedBitmap(Bitmap bm, int newHeight, int newWidth) {

    int width = bm.getWidth();

    int height = bm.getHeight();

    float scaleWidth = ((float) newWidth) / width;

    float scaleHeight = ((float) newHeight) / height;
    Matrix matrix = new Matrix();
    matrix.postScale(scaleWidth, scaleHeight);
    return Bitmap.createBitmap(bm, 0, 0, width, height, matrix, false);

}
public Bitmap decodeBase64String(String input) {
    byte[] decodeByte = Base64.decode(input, 0);
    return BitmapFactory.decodeByteArray(decodeByte, 0, decodeByte.length);
}`

I hope you can help us with our problem. Our customers are really angry if they have to sign multiple times on the devices

Thanks

Laggy performance on Note 4

Hi,

I think simplify-ink is the best Android signature tool you can find. Thats why I'm using this in my new app. But i recognized a problem with the performance of the api, it's really laggy on using with the Samsung Note 4 (it doesn't matter if SPen or Finger). On my development devise the Nexus 4 it is running very smoothly and the signature looks great.

Do you think you can optimize the performance of your tool for the new Galaxy Note? Maybe the performance is laggy because of the resolution the phone has.

Thank you

SVG Support?

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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.