i have a pixel array containing the values from 0 to 255 …
i have passed it to my c++ function …
this pixel array i want to save it to jpeg image file…
how to do it with correct encoding ??
i have converted the array to binary string
and saved it into the file in the below code but it just saves an empty image of 4 byte size …
FILE *file = fopen("/media/internal/wallpapers/04.jpeg", "w+");
fwrite(binaryStr , 1 , sizeof(binaryStr) ,file );
fclose(file);
thnks
From your description it looks like you have YUV-data that you need to convert to jpeg. Correct? Imagemagick is a very powerful tool that can handle this.
From wikipedias entry on YUV:
Y’ values are conventionally shifted and scaled to the range [16, 235] rather than using the full range of [0, 255]. This confusing practice derives from the MPEG standards and explains why 16 is added to Y’ and why the Y’ coefficients in the basic transform sum to 220 instead of 255. U and V values, which may be positive or negative, are summed with 128 to make them always positive
I.e. 0-255 is not a valid range for YUV-data