CreateContent from ByteBuffer – how?

CreateContent from ByteBuffer – how?

BY 28 Sep 2013 Native Application Development

Hi There,

Running the following code works:

  _file_1.Construct( filename_1_jpg );
  _file_1.Read(myByteBuffer);

  _file_2.Construct( filename_2_jpg , "w+"));
  _file_2.write(myByteBuffer);

  contentId = contentManager.CreateContent( filename_2_jpg , outFileName, true, 0);

But if I want to create the content from the bytebuffer, it fails:

  _file_1.Construct( filename_1_jpg );
  _file_1.Read(myByteBuffer);

  contentId = contentManager.CreateContent(myByteBuffer, outFileName, 0);

> [E_INVALID_ARG] byteBuffer is invalid.
> [E_INVALID_ARG] CreateContent failed.

Ok, maybe I have to decode the raw file data:

  _file_1.Construct( filename_1_jpg );
  _file_1.Read(myByteBuffer);

  myByteBuffer_2 = _image.DecodeToBufferN(myByteBuffer, IMG_FORMAT_JPG, BITMAP_PIXEL_FORMAT_RGB565, w, h);
  contentId = contentManager.CreateContent(myByteBuffer_2, outFileName, 0);

This is E_SUCCESS now, but when I open the gallery, I see this:

So it seems the image is lost.

—————————-

So, what is the correct usage of CreateContent using a bytebuffer as source?

Thank you

 

Written by