Closed nottosave closed 12 years ago
Base30 is 'compressed' vector data. Into[][][] is 'uncompressed' but still vector data. The vector data still needs to be 'rendered' to bitmap if you want bitmap (PNG and such).
There are many ways to render. You can code it by hand by converting vectors to line on top of Bitmap object, but I preferred 'rendering' to SVG, and then rendering that to Bitmap. See 'svg' project in the same solution. The output is regular SVG. You can render those using great .net SVGlib (http://svg.codeplex.com/) or external renderer like GraphicsMagic which can render Svg file directly to bitmap format of your choice.
We used the mentioned .Net svg lib. See the Viewer project in this solution for example of rendering https://github.com/willowsystems/SVG-Rendering-Engine-dotNet On Jun 7, 2012 4:39 AM, "nottosave" < reply@reply.github.com> wrote:
I'm trying to save a signature on the server side after returning a Base30 string from a mobile device via jquery mobile.
I tried using the function GetData to convert the signature to save as a PNG image, but how should i get the int[][][] to a saved image in the filesystem? Can anyone give me a C# exampel of how to do this?
Thanks!!
GetData from jSignature.Tools public int[][][] GetData(string data)
/// Returns a .net-specific array of arrays structure representing a single signature stroke /// A compressed string like this one: /// "3E13Z5Y5_1O24Z66_1O1Z3_3E2Z4" /// representing this raw signature data: /// [{'x':[100,101,104,99,104],'y':[50,52,56,50,44]},{'x':[50,51,48],'y':[100,102,98]}] /// turns into this .Net-specific structure (of array or arrays of arrays) /// [[[100,50],[1,2],[3,4],[-5,-6],[5,-6]], [[50,100],[1,2],[-3,-4]]]
Reply to this email directly or view it on GitHub: https://github.com/brinley/jSignature/issues/14
Thank you very much!!!! I will try this tomorrow.
/Ola
I'm using PHP server side for pretty much the same thing.
I get Warning: imagecreatefromstring() [function.imagecreatefromstring]: Data is not in a recognized format
Now I see it's because the image data isn't rendered, it's vector. Thanks dvdotsenko.
Do you have any suggestions for converting with php?
Thanks guys :)
@krazyjakee Although PHP is not my strength, would gladly help (in any way i can) someone put one together, with eye on including it into 'extras' folder.
As with the .Net example, my approach was to think of rendering backwards: 1 where and what kinds of images i need in the end? 2 what lib on my platform can generate these with most ease, quality, stability?
In case of Python (platform i know very well), for example, the choices for #2 were slim: render using PIL or push something to ImageMagic / GraphicsMagic. Since GraphicsMagic / ImageMagic supports SVG-to-[bitmap format of choice] natively, the game turned into:
in case of .Net,
base30 to SVG is very very easy string concatenation (see .Net example converter_toSVG.cs in 'extras' and JavaScript example in jSignature.CompressorSVG.js). If PHP already has some very good imaging lib that reliably does SVG-to-[Bitmap] with resizing etc., I'd say go the same 2-step route. Easier.
There's an untested solution to step 2: http://stackoverflow.com/questions/10289686/rendering-an-svg-file-to-a-png-or-jpeg-in-php using ImageMagick. I will layout some sort of skeleton for a SignatureDataConversion_php folder and convert some of the dotnet code to my best ability. It will be my first fork and push so I apologise if anything goes wrong.
Ok I've pushed to my fork, do you have any input on that?
The PHP-specific conversation is moved to issue #16 (https://github.com/brinley/jSignature/pull/16)
How can i do it by using Java? i want to convert JSignature Base30 into image or base64 at serverside by using Java
I'm trying to save a signature on the server side after returning a Base30 string from a mobile device via jquery mobile.
I tried using the function GetData to convert the signature to save as a PNG image, but how should i get the int[][][] to a saved image in the filesystem? Can anyone give me a C# exampel of how to do this?
Thanks!!
GetData from jSignature.Tools public int[][][] GetData(string data)
/// Returns a .net-specific array of arrays structure representing a single signature stroke /// A compressed string like this one: /// "3E13Z5Y5_1O24Z66_1O1Z3_3E2Z4" /// representing this raw signature data: /// [{'x':[100,101,104,99,104],'y':[50,52,56,50,44]},{'x':[50,51,48],'y':[100,102,98]}] /// turns into this .Net-specific structure (of array or arrays of arrays) /// [[[100,50],[1,2],[3,4],[-5,-6],[5,-6]], [[50,100],[1,2],[-3,-4]]]