Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » Draw, Display, Images, Bitmaps, Icons » Encoding an image in base64
Encoding an image in base64 [message #57546] Sun, 19 September 2021 13:34 Go to previous message
Giorgio is currently offline  Giorgio
Messages: 218
Registered: August 2015
Experienced Member
Hi there,
I have a RichText field that contains some formatted text that I need to convert it to a base64 encoded PNG image.

I've been trying to use PNGEncoder and Encode64() with mixed results:
RichText text;

//text is filled in

ImagePainter w(3000, 100);
w.DrawRect(0, 0, 3000, 100, White());
text.Paint(w, 0, 0, 3000);

PNGEncoder png;
png.SaveFile("C:\\Temp\\richtext.png", w);


The above code works perfectly: I got a PNG image that can be viewed with any image viewer.

Anyway, I need the image to be encoded in base64, so I change the "png.SaveFile()" line above with the following:
String png_string = png.SaveString(w);
SaveFile("C:\\Temp\\test.txt",Encode64(png_string));


If I open the txt file, copy the content and paste it into an online base64 decoder (I tried a few) the image cannot be decoded.

What I do wrong?
Thankks,
gio



 
Read Message
Read Message
Read Message
Previous Topic: Maximum images size in QTF
Next Topic: image viewer
Goto Forum:
  


Current Time: Fri Mar 29 01:05:30 CET 2024

Total time taken to generate the page: 0.01367 seconds