StrokesPlus.net
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Jack Ma  
#1 Posted : Sunday, November 22, 2020 10:26:21 AM(UTC)
Jack Ma

Rank: Member

Reputation:

Groups: Approved
Joined: 11/22/2020(UTC)
Posts: 7
China

Was thanked: 7 time(s) in 2 post(s)
The first script is to convert clipboard image to Base64 string, and then output HTML code to clipboard.
Code:
if (clip.ContainsImage()) {
    var clipboardImage = clip.GetImage();
    var ms = new clr.System.IO.MemoryStream();
    clipboardImage.Save(ms, drawing.System.Drawing.Imaging.ImageFormat.Png);
    ms.Position = 0;
    var base64Img = clr.System.Convert.ToBase64String(ms.GetBuffer());
    var imgHTML = "<img alt='Clipped Image' src='" + "data:image/png;base64," + base64Img + "' />";
    clip.SetText(imgHTML);
    ms.Close();
}


The second script is to get svg file path from clipboard, read it, convert it to Base64 string and output HTML code to clipboard.
Code:
if (clip.ContainsFileDropList()) {
    var clipFileList = clip.GetFileDropList();
    if (clipFileList[0].includes(".svg")) {
        var svgFilePath = clipFileList[0];
        var base64Img = clr.System.Convert.ToBase64String(clr.System.IO.File.ReadAllBytes(svgFilePath));
		var imgHTML = "<img alt='Clipped Image' src='" + "data:image/svg+xml;base64," + base64Img + "' />";
		clip.SetText(imgHTML);
    }    
}
thanks 3 users thanked Jack Ma for this useful post.
Rob on 11/22/2020(UTC), Rob Otter on 11/23/2020(UTC), soooulp on 4/20/2021(UTC)
Rob  
#2 Posted : Sunday, November 22, 2020 11:43:57 AM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,343
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 415 time(s) in 354 post(s)
This is great!
Rob Otter  
#3 Posted : Monday, November 23, 2020 12:49:35 PM(UTC)
Rob Otter

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 10/26/2020(UTC)
Posts: 50
Germany
Location: Darmstadt

Thanks: 15 times
Was thanked: 2 time(s) in 2 post(s)
Thanks Jack Ma, this could come in quite handy one time! Immediately saved it to my macros...
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.