Quantcast
Channel: Cocos Forums - Latest topics
Viewing all articles
Browse latest Browse all 17115

Rendertexture to base64

$
0
0

Hello I need help, I want to get the Base64 string from Rendertexture, I was able to create the PNG file, but I should get the string base64.

I’m doing this code:

auto callback = [&](RenderTexture* rt, const std::string& path){
      //Open file PNG, I don't know if this code it's correct
      Data readData = FileUtils::getInstance()->getDataFromFile(path);
      buffer = (unsigned char*)malloc(sizeof(unsigned char) * (readData.getSize() + 1));
      memcpy(buffer, readData.getBytes(), readData.getSize());
      buffer[readData.getSize()] = '\0';
      std::string readDataStr((const char*)buffer); 
      //String base64 from PNG
      char** out;
      int result  = base64Encode(readData.getBytes()readData.getSize(), out);

    
}
_target->saveToFile(png, Image::Format::PNG, true, callback);

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 17115

Trending Articles