Well now. I seem to have fixed a long standing problem with saving JPEG in 68k.
I was a little perplexed by the new JPEG saving a JPEG file with 0 bytes! Why was it doing that?
So I compiled JPEG sources all the way back to 05-12-19. But each time on 68k it failed to save.
So then I enabled debug and put lots of debug messages in to test all the values. But they looked ok.
So what would cause an empty file on 68k but on x86 and x86_64 the Save JPEG works just fine?
While examining the code I found something suspicious. So I compared to Load_JPEG to confirm.
Sure enough there was an error in the code all this time. Filehandles are slightly different in 68k.
I believe we had that discussion with Nick and Michal Schultz when I was working with ABIv1.
D(bug("jpeg.datatype/SaveJPEG(): Create compressor\n"));
jpeg_create_compress(&cinfo);
//jpeg_stdio_dest(&cinfo, (FILE *)filehandle);
jpeg_stdio_dest(&cinfo, BADDR(filehandle));
//Write to filehandle. jpeg_stdio_src(&cinfo, BADDR(filehandle.bptr));
dest = (my_dest_ptr) cinfo.dest;
dest->pub.empty_output_buffer = my_empty_output_buffer;
dest->pub.term_destination = my_term_destination;
On the line immediately after: jpeg_create_compress(&cinfo);
notice that it says (FILE *)filehandle but in 68k you can't cast a BPTR into a FILE.
As you see in the Load_JPEG it instead used BADDR(filehandle) where filehandle is a BPTR.
So I made one change to the code and now the 68k JPEG datatype can now save 8bit & 24bit.
jpeg_stdio_dest(&cinfo, BADDR(filehandle));
In order to convert BPTR filehandle to FILE we must use BADDR not (FILE*).
So now it works correctly. This only took about 5 hours of troubleshooting to find a small thing!