Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to invoke web service
#6
Use the following code, Successful outputĀ  Tongue

But I feel very troublesomeļ¼ŒSomeone can provide a QM function? I didn't find any relevant information in the entire forum.



Macro IMG2Base64
Code:
Copy      Help
CsScript x
x.AddCode("")

str IMG64 = x.Call("ImgToBase64String" "c:\OCR test.png")
out IMG64

#ret
;using System;
;using System.Collections.Generic;
;using System.Drawing;
;using System.IO;
;using System.Linq;
;using System.Web;
;using System.Drawing.Imaging;

;namespace Html5Image.Tools
;{
;;;;;public class ImageTool
;;;;;{
;;;;;;;;;//Image to base64 encoded text
;;;;;;;;;public static string ImgToBase64String(string Imagefilename)
;;;;;;;;;{
;;;;;;;;;;;;;Bitmap bmp = new Bitmap(Imagefilename);
;;;;;;;;;;;;;//this.pictureBox1.Image = bmp;
;;;;;;;;;;;;;//FileStream fs = new FileStream(Imagefilename + ".txt", FileMode.Create);
;;;;;;;;;;;;;//StreamWriter sw = new StreamWriter(fs);
;
;;;;;;;;;;;;;MemoryStream ms = new MemoryStream();
;;;;;;;;;;;;;bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
;;;;;;;;;;;;;byte[] arr = new byte[ms.Length];
;;;;;;;;;;;;;ms.Position = 0;
;;;;;;;;;;;;;ms.Read(arr, 0, (int)ms.Length);
;;;;;;;;;;;;;ms.Close();
;;;;;;;;;;;;;String strbaser64 = Convert.ToBase64String(arr);
;
;;;;;;;;;;;;;return strbaser64;
;;;;;;;;;}
;
;;;;;;;;;public static Bitmap Base64StringToImage(string base64Img)
;;;;;;;;;{
;;;;;;;;;;;;;byte[] bytes = Convert.FromBase64String(base64Img);
;;;;;;;;;;;;;MemoryStream ms = new MemoryStream();
;;;;;;;;;;;;;ms.Write(bytes, 0, bytes.Length);
;;;;;;;;;;;;;Bitmap bmp = new Bitmap(ms);
;
;;;;;;;;;;;;;return bmp;
;;;;;;;;;}
;
;;;;;;;;;/// <summary>
;;;;;;;;;/// save Picture
;;;;;;;;;/// </summary>
;;;;;;;;;/// <param name="base64Img"></param>
;;;;;;;;;/// <param name="imgPath"></param>
;;;;;;;;;/// <param name="imgFormat">EX: System.Drawing.Imaging.Jpeg </param>
;;;;;;;;;public static void SaveFile(string base64Img, string imgPath, ImageFormat imgFormat )
;;;;;;;;;{
;;;;;;;;;;;;;string dir = Path.GetDirectoryName(imgPath);
;;;;;;;;;;;;;if (!Directory.Exists(dir))
;;;;;;;;;;;;;{
;;;;;;;;;;;;;;;;;Directory.CreateDirectory(dir);
;;;;;;;;;;;;;}
;;;;;;;;;;;;;var bitmap = Base64StringToImage(base64Img);
;;;;;;;;;;;;;bitmap.Save(imgPath, imgFormat);
;;;;;;;;;}
;;;;;}
;}


Messages In This Thread
How to invoke web service - by win - 04-30-2019, 06:41 AM
RE: How to invoke web service - by win - 04-30-2019, 11:27 PM
RE: How to invoke web service - by win - 05-01-2019, 04:34 AM
RE: How to invoke web service - by redbull2k - 05-01-2019, 04:43 PM
RE: How to invoke web service - by win - 05-01-2019, 11:38 PM
RE: How to invoke web service - by win - 05-02-2019, 01:45 AM
RE: How to invoke web service - by Kevin - 05-02-2019, 02:30 AM
RE: How to invoke web service - by win - 05-02-2019, 02:34 AM
RE: How to invoke web service - by Kevin - 05-02-2019, 02:55 AM
RE: How to invoke web service - by win - 05-02-2019, 03:07 AM
RE: How to invoke web service - by Kevin - 05-02-2019, 03:08 AM
RE: How to invoke web service - by win - 05-02-2019, 03:11 AM
RE: How to invoke web service - by Kevin - 05-02-2019, 03:55 AM
RE: How to invoke web service - by win - 05-02-2019, 04:04 AM
RE: How to invoke web service - by Kevin - 05-02-2019, 04:16 AM
RE: How to invoke web service - by win - 05-02-2019, 05:24 AM
RE: How to invoke web service - by Kevin - 05-02-2019, 05:42 AM
RE: How to invoke web service - by win - 05-02-2019, 06:50 AM
RE: How to invoke web service - by win - 05-02-2019, 11:20 AM
RE: How to invoke web service - by win - 05-03-2019, 03:47 AM
RE: How to invoke web service - by redbull2k - 05-03-2019, 02:21 PM
RE: How to invoke web service - by redbull2k - 05-03-2019, 03:26 PM
RE: How to invoke web service - by win - 05-03-2019, 10:10 PM
RE: How to invoke web service - by Kevin - 05-04-2019, 01:27 AM
RE: How to invoke web service - by win - 05-04-2019, 01:57 AM
RE: How to invoke web service - by Kevin - 05-04-2019, 02:32 AM
RE: How to invoke web service - by win - 05-04-2019, 02:56 AM
RE: How to invoke web service - by Kevin - 05-04-2019, 03:04 AM
RE: How to invoke web service - by win - 05-04-2019, 03:13 AM
RE: How to invoke web service - by Kevin - 05-04-2019, 03:17 AM
RE: How to invoke web service - by win - 05-04-2019, 03:27 AM
RE: How to invoke web service - by Kevin - 05-04-2019, 03:33 AM
RE: How to invoke web service - by win - 05-04-2019, 03:40 AM
RE: How to invoke web service - by Kevin - 05-04-2019, 04:19 AM
RE: How to invoke web service - by win - 05-04-2019, 04:29 AM
RE: How to invoke web service - by Kevin - 05-04-2019, 04:36 AM
RE: How to invoke web service - by redbull2k - 05-04-2019, 10:14 PM
RE: How to invoke web service - by win - 05-04-2019, 11:05 PM
RE: How to invoke web service - by redbull2k - 05-04-2019, 11:50 PM
RE: How to invoke web service - by win - 05-05-2019, 02:25 AM
RE: How to invoke web service - by win - 05-05-2019, 07:39 AM
RE: How to invoke web service - by win - 05-05-2019, 10:51 AM
RE: How to invoke web service - by redbull2k - 05-05-2019, 01:02 PM
RE: How to invoke web service - by win - 05-05-2019, 01:18 PM
RE: How to invoke web service - by redbull2k - 05-05-2019, 01:22 PM
RE: How to invoke web service - by win - 05-05-2019, 01:24 PM
RE: How to invoke web service - by redbull2k - 05-05-2019, 02:01 PM
RE: How to invoke web service - by win - 05-05-2019, 03:15 PM
RE: How to invoke web service - by Kevin - 05-05-2019, 08:36 PM
RE: How to invoke web service - by win - 05-05-2019, 09:15 PM
RE: How to invoke web service - by Kevin - 05-05-2019, 09:39 PM
RE: How to invoke web service - by win - 05-05-2019, 11:54 PM
RE: How to invoke web service - by win - 05-06-2019, 01:22 AM
RE: How to invoke web service - by Kevin - 05-06-2019, 02:19 AM
RE: How to invoke web service - by win - 05-06-2019, 02:33 AM
RE: How to invoke web service - by Kevin - 05-06-2019, 02:44 AM
RE: How to invoke web service - by win - 05-06-2019, 02:50 AM
RE: How to invoke web service - by Kevin - 05-06-2019, 03:03 AM
RE: How to invoke web service - by win - 05-06-2019, 03:11 AM
RE: How to invoke web service - by win - 05-06-2019, 02:05 PM
RE: How to invoke web service - by win - 05-06-2019, 10:00 PM
RE: How to invoke web service - by win - 05-06-2019, 11:03 PM
RE: How to invoke web service - by redbull2k - 05-06-2019, 11:31 PM
RE: How to invoke web service - by Kevin - 05-06-2019, 11:40 PM
RE: How to invoke web service - by redbull2k - 05-06-2019, 11:44 PM
RE: How to invoke web service - by win - 05-07-2019, 12:07 AM
RE: How to invoke web service - by Kevin - 05-07-2019, 12:31 AM
RE: How to invoke web service - by redbull2k - 05-07-2019, 12:33 AM
RE: How to invoke web service - by win - 05-07-2019, 12:36 AM
RE: How to invoke web service - by Kevin - 05-07-2019, 01:06 AM
RE: How to invoke web service - by win - 05-07-2019, 01:11 AM
RE: How to invoke web service - by Kevin - 05-07-2019, 02:42 AM
RE: How to invoke web service - by win - 05-07-2019, 03:00 AM
RE: How to invoke web service - by win - 05-07-2019, 01:31 PM
RE: How to invoke web service - by win - 05-07-2019, 11:52 PM
RE: How to invoke web service - by redbull2k - 05-08-2019, 12:45 AM
RE: How to invoke web service - by win - 05-08-2019, 12:49 AM
RE: How to invoke web service - by redbull2k - 05-08-2019, 12:55 AM
RE: How to invoke web service - by win - 05-08-2019, 01:01 AM
RE: How to invoke web service - by redbull2k - 05-08-2019, 01:30 AM
RE: How to invoke web service - by win - 05-08-2019, 01:42 AM
RE: How to invoke web service - by redbull2k - 05-08-2019, 01:56 AM
RE: How to invoke web service - by win - 05-08-2019, 02:10 AM
RE: How to invoke web service - by win - 05-09-2019, 01:40 AM

Forum Jump:


Users browsing this thread: 25 Guest(s)