Created
June 26, 2016 12:59
-
-
Save Ariex/67bb6f2ad008409ebf4b7f8ae9657621 to your computer and use it in GitHub Desktop.
Create a transparent gif spacer with specified width and height
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static string GetBase64GifSpacer(int width, int height){ | |
var bwidth = BitConverter.GetBytes(width); | |
var bheight = BitConverter.GetBytes(height); | |
var bytes = new byte[] { 0x47,0x49,0x46,0x38,0x39,0x61,bwidth[0],bwidth[1],bheight[0],bheight[1],0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x21,0xF9,0x04,0x01,0x00,0x00,0x00,0x00,0x2C,0x00,0x00,0x00,0x00,bwidth[0],bwidth[1],bheight[0],bheight[1],0x00,0x02,0x02,0x44,0x01,0x00,0x3B }; | |
return "data:image/gif;base64,"+Convert.ToBase64String(bytes); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The reason of making this method, is to create a gif spacer image in base64 format with transparent background and dynamic width and height.
demo is available at: https://dotnetfiddle.net/04gsqG