Hello everyone. I've always wanted to embed small images in my themes (icons, logo's, whatever) but I hate hardcoding resource names in my classes.
Of course you can give the user some .png files and let them add them to the resources, but I wanted something better :)
This class can convert images into code (suitable for Visual Studio, I'll explain that later) and convert them back into images.
This way you can embed little icons in your class file!
Visual studio has a maximum line length of 65530 (or something like that). To prevent errors from happening I've added an option to output a VS-compatible string.
To use this, just add the class and use this code:
Convert an image into code:
Convert the code into an image:
Download:
Spoiler (Click to View)
Note: This isn't supposed to be top-notch coding. It's made to work, not made to be 100% perfect and professional. I made it for personal purposes and just decided to share this with you guys.
EDIT: Completely new class, super small yet much better. Better performance, smaller string,... Thanks for the suggestions!
Of course you can give the user some .png files and let them add them to the resources, but I wanted something better :)
This class can convert images into code (suitable for Visual Studio, I'll explain that later) and convert them back into images.
This way you can embed little icons in your class file!
Visual studio has a maximum line length of 65530 (or something like that). To prevent errors from happening I've added an option to output a VS-compatible string.
To use this, just add the class and use this code:
Convert an image into code:
Code
Dim ITC As New ImageToCodeClass
Dim Code as String = ITC.ImageToCode(YourImage)Convert the code into an image:
Code
Dim ITC As New ImageToCodeClass
PictureBox1.Image = ITC.CodeToImage("<YOUR IMAGE CODE HERE>")Download:
Spoiler (Click to View)
Note: This isn't supposed to be top-notch coding. It's made to work, not made to be 100% perfect and professional. I made it for personal purposes and just decided to share this with you guys.
EDIT: Completely new class, super small yet much better. Better performance, smaller string,... Thanks for the suggestions!



