I've got a function that returns a std::string
object. I'm working with Cocoa/CoreGraphics and I need a way to get the data from that string into a CFData
object so that I can feed that into a CGDataProviderCreateWithCFData
object to make a CGImage
.
The CreateCFData
function wants a const UInt8*
object (UInt8
being a typedef for unsigned char
). The string represents the bytes from a decoded Base64 string (image data), so it appears to contain many null "characters" so the obvious casting of the .c_str()
output to an unsigned char*
object won't work.
I'm less experienced with C++ and very new to Cocoa/CoreGraphics, so if there's a much better way to accomplish what I'm wanting to do please let me know.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…