com.pdftools.pdf2image.TiffJpegImageOptions Maven / Gradle / Ivy
Show all versions of pdftools-sdk Show documentation
/****************************************************************************
*
* File: TiffJpegImageOptions.java
*
* Description: PDFTOOLS TiffJpegImageOptions Class
*
* Author: PDF Tools AG
*
* Copyright: Copyright (C) 2023 - 2024 PDF Tools AG, Switzerland
* All rights reserved.
*
* Notice: By downloading and using this artifact, you accept PDF Tools AG's
* [license agreement](https://www.pdf-tools.com/license-agreement/),
* [privacy policy](https://www.pdf-tools.com/privacy-policy/),
* and allow PDF Tools AG to track your usage data.
*
***************************************************************************/
package com.pdftools.pdf2image;
import com.pdftools.sys.*;
import com.pdftools.internal.*;
import java.util.EnumSet;
import java.time.OffsetDateTime;
/**
* The settings for TIFF output images using the JPEG compression algorithm
*
* TIFF allows images to be compressed with JPEG (Joint Photographic Experts Group), which is a lossy
* compression algorithm. JPEG provides a high compression ratio for
* 8 and 24 bit images. It is best suited for TIFFs containing
* photographs and little or no text.
*
* For the output file name, it is recommended to use the file extension ".tif".
*
*/
public class TiffJpegImageOptions extends com.pdftools.pdf2image.ImageOptions
{
protected TiffJpegImageOptions(long handle)
{
super(handle);
}
/**
* @hidden
*/
public static TiffJpegImageOptions createDynamicObject(long handle)
{
return new TiffJpegImageOptions(handle);
}
/**
*
*/
public TiffJpegImageOptions()
{
this(newHelper());
}
private static long newHelper()
{
long handle = newNative();
if (handle == 0)
{
switch (getLastErrorCode())
{
case 0: throw new RuntimeException("An unexpected error occurred");
default: throwLastRuntimeException();
}
}
return handle;
}
/**
* The JPEG quality factor (Getter)
*
* Get or set the JPEG compression quality.
* Valid values are {@code 1}, or {@code 100}, or in between.
*
* Default: {@code 85}
*/
public int getJpegQuality()
{
int retVal = getJpegQualityNative(getHandle());
if (retVal == 0)
{
switch (getLastErrorCode())
{
case 0: break;
default: throwLastRuntimeException();
}
}
return retVal;
}
/**
* The JPEG quality factor (Setter)
*
* Get or set the JPEG compression quality.
* Valid values are {@code 1}, or {@code 100}, or in between.
*
* Default: {@code 85}
*
* @throws IllegalArgumentException The given value is smaller than 1 or greater than 100.
*/
public void setJpegQuality(int value)
{
boolean retVal = setJpegQualityNative(getHandle(), value);
if (!retVal)
{
switch (getLastErrorCode())
{
case 0: throw new RuntimeException("An unexpected error occurred");
case 3: throw new IllegalArgumentException(getLastErrorMessage());
default: throwLastRuntimeException();
}
}
}
/**
* The color space of the output image (Getter)
*
* Get or set the color space. If null, the blending color space of the page is used.
*
* Default: {@link JpegColorSpace#RGB }
*/
public com.pdftools.pdf2image.JpegColorSpace getColorSpace()
{
Integer retVal = getColorSpaceNative(getHandle());
if (retVal == null)
{
switch (getLastErrorCode())
{
case 0: break;
default: throwLastRuntimeException();
}
return null;
}
return com.pdftools.pdf2image.JpegColorSpace.fromValue(retVal);
}
/**
* The color space of the output image (Setter)
*
* Get or set the color space. If null, the blending color space of the page is used.
*
* Default: {@link JpegColorSpace#RGB }
*/
public void setColorSpace(com.pdftools.pdf2image.JpegColorSpace value)
{
boolean retVal = setColorSpaceNative(getHandle(), value == null ? 0 : value.getValue(), value == null);
if (!retVal)
{
switch (getLastErrorCode())
{
case 0: throw new RuntimeException("An unexpected error occurred");
default: throwLastRuntimeException();
}
}
}
private static native long newNative();
private native int getJpegQualityNative(long handle);
private native boolean setJpegQualityNative(long handle, int value);
private native Integer getColorSpaceNative(long handle);
private native boolean setColorSpaceNative(long handle, int value, boolean isNull);
}