Xojo Conferences

Platforms to show: All Mac Windows Linux Cross-Platform

JPEGTransformationMBS class

Type Topic Plugin Version macOS Windows Linux Console & Web iOS
class JPEG MBS Images Plugin 3.2 Yes Yes Yes Yes No
Function: A class to wrap the jpegtran utility.
Although rotating and flipping data expressed as DCT coefficients is not hard, there is an asymmetry in the JPEG format specification for images whose dimensions aren't multiples of the iMCU size. The right and bottom image edges are padded out to the next iMCU boundary with junk data; but no padding is possible at the top and left edges. If we were to flip the whole image including the pad data, then pad garbage would become visible at the top and/or left, and real pixels would disappear into the pad margins --- perhaps permanently, since encoders & decoders may not bother to preserve DCT blocks that appear to be completely outside the nominal image area. So, we have to exclude any partial iMCUs from the basic transformation.

Transpose is the only transformation that can handle partial iMCUs at the right and bottom edges completely cleanly. Mirror horizontal can flip partial iMCUs at the bottom, but leaves any partial iMCUs at the right edge untouched. Similarly mirror vertical leaves any partial iMCUs at the bottom edge untouched. The other transforms are defined as combinations of these basic transforms and process edge blocks in a way that preserves the equivalence.

The "trim" option causes untransformable partial iMCUs to be dropped; this is not strictly lossless, but it usually gives the best-looking result for odd-size images. Note that when this option is active, the expected mathematical equivalences between the transforms may not hold. (For example, -rot 270 -trim trims only the bottom edge, but -rot 90 -trim followed by -rot 180 -trim trims both edges.)

We also offer a "force to grayscale" option, which simply discards the chrominance channels of a YCbCr image. This is lossless in the sense that the luminance channel is preserved exactly. It's not the same kind of thing as the rotate/flip transformations, but it's convenient to handle it as part of this package, mainly because the transformation routines have to be aware of the option to know how many components to work on.

Bases on libjpeg.

Feedback, Comments & Corrections

This class has no sub classes.

Some examples which use this class:

Blog Entries

The items on this page are in the following plugins: MBS Images Plugin.

JPEGMovieMBS   -   JSClassMBS

The biggest plugin in space...

MBS Xojo Plugins