The quality factor used when saving an image file depends upon its file format. The value used describes the tradeoff between quality and compression.
For the Leadtools.Codecs.RasterCodecs class, use the following table to determine which quality factor will be used:
|RasterImageFormat.Abc and RasterImageFormat.TifAbc||CodecsAbcSaveOptions.QualityFactor.|
|RasterImageFormat.Cmp||CodecsJpegSaveOptions.CmpQualityFactorPredefined or CodecsJpegSaveOptions.QualityFactor if CodecsJpegSaveOptions.CmpQualityFactorPredefined is set to CodecsCmpQualityFactorPredefined.Custom.|
|All other formats that support a quality factor (for example, JPEG, JPEG 2000, etc.)||CodecsJpegSaveOptions.QualityFactor.|
You can specify a quality factor when saving an image file to LEAD, JFIF, LEAD2JFIF, JTIF, LEAD1JTIF, or LEAD2JTIF file formats. Valid values range from 2 to 255, where 2 is the highest quality and 255 is the most compression.
There is no subsampling for grayscale (8-, 12-, or 16-bit) files. Therefore, only Jpeg and TifJpeg are supported for grayscale files. Jpeg411, Jpeg422, TifJpeg411 and TifJpeg422 are supported only for 24-bit bitmaps.
For LEAD CMP compression (8-bit, 12-bit, and 24-bit only), set the CodecsJpegSaveOptions.CmpQualityFactorPredefined property to one of the following enhanced options:
|Quality Factor||Predefined Options for LEAD Only|
|CodecsCmpQualityFactorPredefined.PerfectQuality1||Perfect quality 1. This option compresses all colors of a 24-bit file and maintains the quality of the original image at a smaller file size. As the name suggests, there is no visual loss of color at this setting.|
|CodecsCmpQualityFactorPredefined.PerfectQuality2||Perfect quality 2. Produces a smaller file size than CodecsCmpQualityFactorPredefined.PerfectQuality1, while maintaining similar quality.|
|CodecsCmpQualityFactorPredefined.SuperQuality||Quality far more important than size. Removes colors not noticed by the human eye. Most viewers cannot tell the difference between an image compressed at this level and the original image.|
|CodecsCmpQualityFactorPredefined.Quality||Quality more important than size. While more colors are removed, most of them are colors or shades that are close to one another. The compressed image will appear very much like the original image. It will take some study to see the difference.|
|CodecsCmpQualityFactorPredefined.QualityAndSize||Quality and size equally important. This option provides the highest compression while maintaining good image quality. Try this option first, then move up or down the list accordingly to obtain acceptable compression size and image quality.|
|CodecsCmpQualityFactorPredefined.Sharp||Size more important that quality (sharp). Recommended for images that have sharp edges (for example, an image that has a text overlay or one with many straight lines). While it creates a larger file than the next option, it retains better edges.|
|CodecsCmpQualityFactorPredefined.LessTiling||Size more important than quality (less tiling). This option produces less tiling in the image than the previous options. However, it may distort text or straight lines. It is a good option for image database applications.|
|CodecsCmpQualityFactorPredefined.MaximumQuality||Maximum compression while keeping quality. This option provides maximum compression while maintaining as high as possible image quality.|
|CodecsCmpQualityFactorPredefined.MaximumCompression||Maximum compression. This option gives maximum compression. It is equivalent to a quality factor of 255.|
|CodecsCmpQualityFactorPredefined.Custom||Custom quality factor. Use the value set in the CodecsJpegSaveOptions.QualityFactor property when saving LEAD compressed files.|
For the CMW format, the quality factor can be 0 (lossless compression) or between 2 and 255 (for lossy compression). 2 = highest quality and 255 = highest compression.
For the PNG format, the quality factor can be a value between 0 and 10. 0 = (default compression), 1 (fastest compression) to 9 (highest compression ratio), 10 (no compression). Use the CodecsPngSaveOptions.QualityFactor property to set the PNG quality factor.
For JP2 and J2K files, the quality factor can be a value between -1 and 255. Both -1 and 0 represent lossless compression, whereas all the values between 1 and 255 are considered as compression ratios. For example, a quality factor of 10 is a compression ratio of 10. A quality factor of 1 gives the best lossy quality, while a quality factor of 255 gives the highest compression.
If the compression control used by the toolkit when saving J2K files is CodecsJpeg2000CompressionControl.QualityFactor, then the compression used is based on the value passed to the CodecsJpegSaveOptions.QualityFactor property. For more information about setting the options for saving J2K files, refer to Leadtools.Codecs.CodecsJpeg2000SaveOptions.
For the JLS and JXR files, the quality factor can be a value between 2 and 255 (lossy compression), or the value 0 (lossless compression).
For the FlashPix (RasterImageFormat.FpxJpegQFactor and RasterImageFormat.FpxJpeg) and EXIF (RasterImageFormat.ExifJpeg) files, the quality factor can be a value between 2 and 255, where 2 represents the highest quality and 255 represents the most compression.
|Quality Factor||Predefined options for LEAD only|
|CodecsAbcQualityFactor.Lossless||Lossless compression. This option compresses a 1-bit file and maintains image data unchanged. Highest quality.|
|CodecsAbcQualityFactor.VirtualLossless||Lossy compression. This option removes the image's noisy pixels and compresses it to a smaller file size than CodecsAbcQualityFactor.Lossless.|
|CodecsAbcQualityFactor.RemoveBorder||Lossy compression. This option removes the image's border, if it exists, and compresses it to a smaller file size than CodecsAbcQualityFactor.VirtualLossless.|
|CodecsAbcQualityFactor.Enhance||Lossy compression. This option cleans up the image, removes its border if it exists, and compresses it to a smaller file size than CodecsAbcQualityFactor.RemoveBorder does.|
|CodecsAbcQualityFactor.Modified1||Lossy compression. This option cleans up the image, removes its border if it exists, and compresses it to a smaller file size than CodecsAbcQualityFactor.Enhance does. However, it may distort text or straight lines.|
|CodecsAbcQualityFactor.Modified1Fast||Same as CodecsAbcQualityFactor.Modified1 without the border remove or image clean processes|
|CodecsAbcQualityFactor.Modified2||Lossy compression. This option cleans up the image, removes its border if it exists, and compresses it to a smaller file size than CodecsAbcQualityFactor.Modified1 does. However, it may distort text or straight lines. Maximum compression.|
|CodecsAbcQualityFactor.Modified2Fast||Same as CodecsAbcQualityFactor.Modified2 without the border remove or image clean processes.|
|CodecsAbcQualityFactor.Modified3||Lossy compression. Provides faster encode and decode speed than CodecsAbcQualityFactor.Modified1 or CodecsAbcQualityFactor.Modified2. Provides the maximum compression.|
|CodecsAbcQualityFactor.Modified3Fast||Same as CodecsAbcQualityFactor.Modified3 without the border remove or image clean processes.|
|CodecsAbcQualityFactor.LosslessFast||Faster lossless compression than CodecsAbcQualityFactor.Lossless. This option compresses a 1-bit file and maintains image data unchanged. Highest quality does not produce compression ratios as high as CodecsAbcQualityFactor.Lossless.|
|CodecsAbcQualityFactor.LossyFast||Lossy compression is the fastest ABC lossy compression option. It does not produce compression ratios as high as the other lossy options.|
Use the CodecsAbcSaveOptions.QualityFactor property to set the ABC quality factor.