This documentation is for the old version. Go to the latest Graphics Mill docs

LosslessJpegTransform.AlignToSampleSize Method (Rectangle, JpegAlignToSampleSizeMode)

Aligns coordinates of the given rectangle to the JPEG sample size.

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

Syntax

Visual Basic
Public Function AlignToSampleSize ( _
	rectangle As Rectangle, _
	mode As JpegAlignToSampleSizeMode _
) As Rectangle
C#
public Rectangle AlignToSampleSize(
	Rectangle rectangle,
	JpegAlignToSampleSizeMode mode
)

Parameters

rectangle

Type: System.Drawing.Rectangle

Rectangle which needs to be aligned by the JPEG sample size.
mode

Type: Aurigma.GraphicsMill.Codecs.JpegAlignToSampleSizeMode

JpegAlignToSampleSizeMode value which specifies whether to align width and height. It is not obligatory to align width and height if you just crop the JPEG. But if you need to insert the bitmap into JPEG (using WritePatched(String, Point, Bitmap) method), you should align width and height as well (otherwise you will have noise at right and bottom edge of inserted bitmap).

Return Value

Rectangle which contains coordinates aligned to JPEG sample size. It is always greater or equal than the input rectangle.

Remarks

This method is used when you need to crop a part of a JPEG file without recompression or overwrite some portion of JPEG file 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 crop or write bitmap by arbitrary coordinates. That's why you need to align coordinates by the JPEG sample size.

See Also

Reference