Ive installed libjpeg-turbo on my mac and added the jar and libs to my eclipse project. Im trying to create jpeg byte[] from my bufferedimage:
TJCompressor tj = new TJCompressor();
tj.compress(image, TJ.PF_BGR);
The error I get is: java.lang.Exception: tjBufSize(): Invalid argument
I use a custom robot to create my bufferedimage with the type TYPE_3BYTE_BGR. I can create a byte[] using ImageIO but its to slow.
I tried to find some tutorials on the java wrapper, but I havnt found any that encode a jpeg from a bufferedimage. I would be very grateful if someone could help me.
You appear to be passing in the wrong type of argument into the method. You are passing in a pixel format when you should be passing in zero or more flags from the
TJ
class (prefixed with "FLAG_"). The pixel format type will be automatically detected by theTJCompressor
object.Make sure you set the chrominance subsampling level and JPEG quality to your desired levels before using the
TJCompressor
as well.Sample code: