Пример #1
0
 /**
  * Associate an uncompressed source image with this compressor instance.
  *
  * @param srcImage image buffer containing RGB or grayscale pixels to be compressed
  * @param x x offset (in pixels) of the region from which the JPEG image should be compressed,
  *     relative to the start of <code>srcImage</code>.
  * @param y y offset (in pixels) of the region from which the JPEG image should be compressed,
  *     relative to the start of <code>srcImage</code>.
  * @param width width (in pixels) of the region in the source image from which the JPEG image
  *     should be compressed.
  * @param pitch bytes per line of the source image. Normally, this should be <code>
  *     width * TJ.pixelSize(pixelFormat)</code> if the source image is unpadded, but you can use
  *     this parameter to, for instance, specify that the scanlines in the source image are padded
  *     to a 4-byte boundary or to compress a JPEG image from a region of a larger source image.
  *     You can also be clever and use this parameter to skip lines, etc. Setting this parameter to
  *     0 is the equivalent of setting it to <code>width *
  * TJ.pixelSize(pixelFormat)</code>.
  * @param height height (in pixels) of the region in the source image from which the JPEG image
  *     should be compressed.
  * @param pixelFormat pixel format of the source image (one of {@link TJ TJ.PF_*})
  */
 public void setSourceImage(
     byte[] srcImage, int x, int y, int width, int pitch, int height, int pixelFormat)
     throws Exception {
   if (handle == 0) init();
   if (srcImage == null
       || x < 0
       || y < 0
       || width < 1
       || height < 1
       || pitch < 0
       || pixelFormat < 0
       || pixelFormat >= TJ.NUMPF) throw new Exception("Invalid argument in setSourceImage()");
   srcBuf = srcImage;
   srcWidth = width;
   if (pitch == 0) srcPitch = width * TJ.getPixelSize(pixelFormat);
   else srcPitch = pitch;
   srcHeight = height;
   srcPixelFormat = pixelFormat;
   srcX = x;
   srcY = y;
 }
Пример #2
0
 /** Create a TurboJPEG compressor instance. */
 public TJCompressor() throws Exception {
   init();
 }