public void id001_Sizes() { var c = new jSignature.Tools.Base30Converter(); var uncompresseddataobject = c.Base30ToNative(compressedtestdata); var stats = new jSignature.Tools.Stats(uncompresseddataobject); // above sig has the following limits // x 121 to 496 // y 66 to 233 Assert.AreEqual( new int[] { 121, 66, 496, 233 } , stats.ContentLimits ); Assert.AreEqual( new int[] { 496 - 121 + 1, 233 - 66 + 1 } , stats.ContentSize ); Assert.AreEqual( new int[] { 496, 233 } , stats.Size ); }
public void id001_Sizes() { var c = new jSignature.Tools.Base30Converter(); var uncompresseddataobject = c.GetData(compressedtestdata); var stats = new jSignature.Tools.Stats(uncompresseddataobject); // above sig has the following limits // x 121 to 496 // y 66 to 233 Assert.AreEqual( new int[] {121, 66, 496, 233} , stats.ContentLimits ); Assert.AreEqual( new int[] { 496 - 121 + 1, 233 - 66 + 1 } , stats.ContentSize ); Assert.AreEqual( new int[] { 496, 233 } , stats.Size ); }
public void id002_DecompressSig() { // [[[100,50],[1,2],[3,4],[-5,-6],[5,-6]], [[50,100],[1,2],[-3,-4]]]; // [{'x':[100,101,104,99,104],'y':[50,52,56,50,44]},{'x':[50,51,48],'y':[100,102,98]}] // "3E13Z5Y5_1O24Z66_1O1Z3_3E2Z4" int[][][] shouldbe = new int[][][] { new int[][] { new int[] { 100, 50 } , new int[] { 1, 2 } , new int[] { 3, 4 } , new int[] { -5, -6 } , new int[] { 5, -6 } } , new int[][] { new int[] { 50, 100 } , new int[] { 1, 2 } , new int[] { -3, -4 } } }; var c = new jSignature.Tools.Base30Converter(); Assert.AreEqual( shouldbe , c.GetData("3E13Z5Y5_1O24Z66_1O1Z3_3E2Z4") ); }
public void id003_ToSVG_External() { var data = new jSignature.Tools.Base30Converter().Base30ToNative("3E13Z5Y5_1O24Z66_1O1Z3_3E2Z4"); string actual = jSignature.Tools.SVGConverter.ToSVG(data); // System.IO.File.WriteAllText(Common.SOURCE_PATH + "\\samples\\reference_svg_smoothed.svg", actual); string shouldbe = System.IO.File.ReadAllText(Common.SOURCE_PATH + "\\samples\\reference_svg_smoothed.svg"); Assert.AreEqual( shouldbe , actual ); }
public void id001_decompressleg() { int[] leg1x = new int[] {236, 233, 231, 229, 226, 224, 222, 216, 213, 210, 205, 202, 200, 198, 195, 193, 191, 189, 186, 183, 180, 178, 174, 172}; int[] leg1xVectorized = new int[leg1x.Length]; int last = 0; for (int i = 0; i < leg1x.Length; i++) { leg1xVectorized[i] = leg1x[i] - last; last = leg1x[i]; } var c = new jSignature.Tools.Base30Converter(); Assert.AreEqual( leg1xVectorized , c.DecompressStrokeLeg("7UZ32232263353223222333242") ); }
public void id001_decompressleg() { int[] leg1x = new int[] { 236, 233, 231, 229, 226, 224, 222, 216, 213, 210, 205, 202, 200, 198, 195, 193, 191, 189, 186, 183, 180, 178, 174, 172 }; int[] leg1xVectorized = new int[leg1x.Length]; int last = 0; for (int i = 0; i < leg1x.Length; i++) { leg1xVectorized[i] = leg1x[i] - last; last = leg1x[i]; } var c = new jSignature.Tools.Base30Converter(); Assert.AreEqual( leg1xVectorized , c.DecompressStrokeLeg("7UZ32232263353223222333242") ); }
public void id003_DecompressSigCompressSig() { //The sample signature will be decompressed and then compression will take place //immediately after that. The end result should be identical to the input. string compressedSig = "4A8865240Z12020020110200Y1442346668865543232010Z14854Y3858a77d65653212001301002544463334324_1TZ243532Ydgeglgb9646Z7ajicob74522000Y114465865a5511016a7c7a5a410Z15463566Y3545541111Z1332653Y1_bS2Z112344200Y25845583464662200Z40000002330Y216333343234_5DZ374331Y3a8667a5110Z34abfbc896Y4885885333Z5351Y233553332_aF_3K"; Base30Converter bc = new Base30Converter(); //Perform the decompression int[][][] dec = bc.Base30ToNative(compressedSig); //Now convert the output back to being compressed string comp = bc.NativeToBase30(dec); //The orignal input should be the same as our latest result Assert.AreEqual(compressedSig, comp); }
public void id002_DecompressSig() { // [[[100,50],[1,2],[3,4],[-5,-6],[5,-6]], [[50,100],[1,2],[-3,-4]]]; // [{'x':[100,101,104,99,104],'y':[50,52,56,50,44]},{'x':[50,51,48],'y':[100,102,98]}] // "3E13Z5Y5_1O24Z66_1O1Z3_3E2Z4" int[][][] shouldbe = new int[][][] { new int[][] { new int[] {100, 50} ,new int[] {1, 2} ,new int[] {3, 4} ,new int[] {-5, -6} ,new int[] {5, -6} } , new int[][] { new int[] {50, 100} ,new int[] {1, 2} ,new int[] {-3, -4} } }; var c = new jSignature.Tools.Base30Converter(); Assert.AreEqual( shouldbe , c.Base30ToNative("3E13Z5Y5_1O24Z66_1O1Z3_3E2Z4") ); }
public void id003_ToSVG_External() { var data = new jSignature.Tools.Base30Converter().GetData("3E13Z5Y5_1O24Z66_1O1Z3_3E2Z4"); string actual = jSignature.Tools.SVGConverter.ToSVG(data); // System.IO.File.WriteAllText(Common.SOURCE_PATH + "\\samples\\reference_svg_smoothed.svg", actual); string shouldbe = System.IO.File.ReadAllText(Common.SOURCE_PATH + "\\samples\\reference_svg_smoothed.svg"); Assert.AreEqual( shouldbe , actual ); }
public void id003_ToSVG_External() { var data = new jSignature.Tools.Base30Converter().Base30ToNative("3E13Z5Y5_1O24Z66_1O1Z3_3E2Z4"); string actual = jSignature.Tools.SVGConverter.ToSVG(data); // System.IO.File.WriteAllText(Common.SOURCE_PATH + "\\samples\\reference_svg_smoothed.svg", actual); var sampleFilePath = Path.Combine(Common.SOURCE_PATH, "samples\\reference_svg_smoothed.svg"); Assert.IsTrue(File.Exists(sampleFilePath), "Sample File not found!"); string shouldbe = System.IO.File.ReadAllText(sampleFilePath); Assert.AreEqual(shouldbe, actual); }