On Jul 3, 2021, at 8:48 PM, 'Kevin McBride' via libjpeg-turbo User Discussion/Support <libjpeg-t...@googlegroups.com> wrote:
--<output00001.jpeg>
You received this message because you are subscribed to the Google Groups "libjpeg-turbo User Discussion/Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to libjpeg-turbo-u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/libjpeg-turbo-users/ba7a1531-7b23-4631-b084-1c890d432de2n%40googlegroups.com.
<test.txt><output00001.jpeg>
On Jul 4, 2021, at 3:38 PM, 'Kevin McBride' via libjpeg-turbo User Discussion/Support <libjpeg-t...@googlegroups.com> wrote:
I found the problem in my code. I was not correctly converting the image data into a single dimension unsigned char array. I changed the code to the following, and I managed to get the PNG-style array converted into the array that TurboJPEG accepts. I also corrected the pitch.srcbuf2 = srcbuf = (unsigned char *)calloc(x, y);
if ( srcbuf == NULL )
return 0;
/* Fill the jpeg buffer. */
for ( i=0; i < y; i++ )
{
memcpy(srcbuf2, image[i], x);
srcbuf2 += x;
}Now the image comes out looking the same as the PNG. First image is the JPEG, second image is the PNG.
<output00001.jpeg><output00001.png>
To view this discussion on the web visit https://groups.google.com/d/msgid/libjpeg-turbo-users/7a60d672-f2cf-438c-bb83-4b45cd08ff58n%40googlegroups.com.
<output00001.jpeg><output00001.png>
uint8_t * is the same as unsigned char *,
so the TurboJPEG API can read directly from that. libjpeg-turbo
can also read directly from an array of uint8_t pointers, much
like libpng can, but you would have to use the libjpeg API
rather than the TurboJPEG API in order to do that. I would
suggest that you avoid the uint8_t * --> uint8_t **
conversion unless using libpng.
To view this discussion on the web visit https://groups.google.com/d/msgid/libjpeg-turbo-users/cdc2c4e2-b39c-4616-a5c9-bb6e56fc7930n%40googlegroups.com.