Crops a portion of the uncompressed JPEG image and writes it to specified stream.
Namespace:
Aurigma.GraphicsMill.Codecs
Assembly:
Aurigma.GraphicsMill (in Aurigma.GraphicsMill.dll)
Type: System.IO.Stream
The stream where you want to save the result.Type: System.Drawing.Rectangle
Rectangle object which specifies a portion of the image you need to crop. The rectangle must be inside the image. Note, coordinates of this rectangle and coordinates of the cropped portion of image may be different (see Remarks section for more details).You can use this method to recompress only a part of an image. For example, let's assume you want to apply a watermark to an image or remove an effect of red eyes. It obviously makes sense to recompress only that part of image which you modify without recompressing the other parts. It can be easily achieved with the following algorithm:
Due to specifics of JPEG, you cannot specify arbitrary coordinates to crop. Its top-left corner should be aligned on the size of JPEG sample data. Typically it is a number divisible by 8. To calculate the actual rectangle, you can use the AlignToSampleSize(Point, Bitmap) method. You just pass your rectangle to this method and it returns the nearest rectangle (with modified position and dimensions aligned to the JPEG sample size).
If you pass a rectangle which is not aligned, Graphics Mill for .NET automatically aligns it. As a result, coordinates of the left-top corner of this rectangle will be rounded down by the JPEG sample size but coordinates of the right-bottom corner will not be changed. For example, if you specify this rectangle (11, 11, 20, 20) it will be aligned to (8, 8, 23, 23) if the JPEG sample size is 8x8.