it's posible save a image into a c++ source code?
#include <string>
int main(){
std::string = "<full code of a .png for example>";
//...
}
The problem it's that a image got a lot of characters like '\'... and copy and pasting it from a hexadecimal editor generates errors.
I don't want load the image from a .png file, i want get the image code directly into a string.
This is generally done by saving the image into a base64 encoded string. It requires more bytes to store, but has the advantage of being a string. You can use an online tool to convert your image to a base64 encoded string that you can copy into your source file.
string base64 = "copy encoded string here";
See this question for more details on how to decode that string into an image. Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With