Init Image by data in Cocs2d-x 2.2.6 to 3.17

My boss asked me to update his 2.2.6 project to 3.17 version
Im getting troubel in here!
He have function init image by void* data,int datalen,int and type image (PNG or JPG)
im try to clone it in 3.17
what im wrong?
And how to fix it,
Thanks for all your supports!

Maybe you should use this method:
Texture2D* TextureCache::addImage(Image *image, const std::string &key) .

For the first parameter, you can use this method to init a Image object:
bool Image::initWithImageData(const unsigned char * data, ssize_t dataLen)