LosslessJpeg.AlignToMCUSize Method (Rectangle, JpegAlignToSampleSizeMode)

Aligns the rectangle to JPEG Minimum Coded Units (MCU).

Namespace: Aurigma.GraphicsMill.Codecs
Assembly: Aurigma.GraphicsMill (in Aurigma.GraphicsMill.dll)


public Rectangle AlignToMCUSize(
	Rectangle rectangle,
	JpegAlignToSampleSizeMode mode



Type: System.Drawing.Rectangle

A Rectangle to align to MCU.

Type: Aurigma.GraphicsMill.Codecs.JpegAlignToSampleSizeMode

A JpegAlignToSampleSizeMode specifying whether to align only coordinates of the upper-left corner, or width and height also. See the Remerks section for details.

Return Value

A Rectangle aligned to MCU. It is always greater or equal than the input rectangle.


This method is used when you need overwrite some portion of JPEG image by some bitmap. Since JPEG compressed data is stored in blocks (samples) of several pixels (typically 8, 16, or other number divisible by 8), you cannot write bitmap by arbitrary coordinates. That's why you need to align coordinates by JPEG Minimum Coded Units (MCU).

If you need just to crop an image and you do not want to use it as patch for another image, you can use the Crop value. In this case the width and height of the cropping rectangle can be arbitrary.

However if you are going to put this image onto another (i.e. patch it), the width and height of this image must be aligned. In this case you should use Patch value.

See Also