Search code examples
androidc++cimagelibjpeg

How to get the jpeg image array from an unsigned char* array?


I am doing android native development using libjpeg9. The image data I get from android camera is compressed in jpeg format. Then the data is transferred to native c++ function as an unsigned char* array. As required by function jpeg_mem_src JPP((j_decompress_ptr cinfo,unsigned char * inbuffer,unsigned long insize)) of libjpeg9, the size of the array which is the 'inbuffer' parameter should be provided.

As far as I know, sizeof function cannot be used to get the size of the array because it is only a pointer. We also do not want to change the interface of our c++ function to transfer the size of the array.

So I want to get the size of the array from the header of jpeg. Does anyone know the position of the header where I can get the size of this jpeg image array size?

Any help will be appreciated!


Solution

  • Does anyone know the position of the header where I can get the size of this jpeg image array size?

    There isn't one.

    Any help will be appreciated!

    Change the interface of your c++ function to transfer the size of the array.