I recently asked a question, How to create an image in GDI + from Base64 encoding in C ++? that got the answer that led me to the answer.
Now I need to do the opposite - I have an image in GDI +, whose image data I need to turn into a Base64 encoded string. By nature, it is not easy.
The essence of the problem is that the image in GDI + can save its data either to a file or to IStream *. I do not want to save the file, so I need to use the resulting stream. The problem is that my knowledge is breaking.
This first part is what I found out in another question
( Base64 code )
And now I'm going to perform an operation on the resulting image, in this case, turning it, and now I want the Base64 equivalent string to be ready.
// Perform operation (rotate) image.RotateFlip(Gdiplus::Rotate180FlipNone); IStream* oStream = NULL; CLSID tiffClsid; GetEncoderClsid(L"image/tiff", &tiffClsid); // Function defined elsewhere image.Save(oStream, &tiffClsid); // And here where I'm stumped.
( GetEncoderClsid )
So I end at the end, this is an IStream * object. But here, where both my knowledge and Google break down for me. IStream does not have to be the object itself, it is an interface for other types of streams. I took the road from getting the line -> Image in reverse order, but I don’t know how to determine the size of the stream, which, apparently, is the key for this route.
How can I go from IStream * to a string (which I will encode Base64)? Or is there a much better way to go from GDI + Image to a string?
source share