GithubHelp home page GithubHelp logo

I added JPEG support :) about jsignature HOT 4 OPEN

PeteW avatar PeteW commented on June 19, 2024
I added JPEG support :)

from jsignature.

Comments (4)

beveltd avatar beveltd commented on June 19, 2024

how are you actually using this in jsignature?

from jsignature.

PeteW avatar PeteW commented on June 19, 2024

I am using this in a phonegap application which captures sugnatures and stores them as 64-bit encoded jpeg values which can be streamed back to the server

from jsignature.

joaopiopedreira avatar joaopiopedreira commented on June 19, 2024

Hi, I'm trying to use jsignature with that in mind, too (capture signature in Meteorjs app and send it back to SQL Server). How should I go about this? Thanks

from jsignature.

joaopiopedreira avatar joaopiopedreira commented on June 19, 2024

Finally got this to work using PeteW solution.

Noticed though that the jpeg resulting image had its colors reversed, so I've added the tweek below. Hope it can help somebody :-)

    var exportplugins = {
        'defaultold':function(data){return this.toDataURL()}
        , 'default': function(data){

            // Invert colors
            var imageData = this.getContext("2d").getImageData(0, 0, this.width, this.height);
            var imgData = imageData.data;

            for(var i = 0; i < imgData.length; i += 4) {
                // red
                imgData[i] = 255 - imgData[i];
                // green
                imgData[i + 1] = 255 - imgData[i + 1];
                // blue
                imgData[i + 2] = 255 - imgData[i + 2];
            }

            // overwrite original image
            this.getContext("2d").putImageData(imageData, 0, 0);

            return new JPEGEncoder().encode(
                imageData,
                    10
            );
        }

from jsignature.

Related Issues (20)

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.