Modify Clipping Path Explicitly
View as MarkdownModifies clipping path explicitly.
Code Snippet
using (var reader = new JpegReader("Apple.jpg"))
using (var bitmap = reader.Frames[0].GetBitmap())
{
var crop = new Crop(20, 20, bitmap.Width - 40, bitmap.Height - 40);
var cropped = crop.Apply(bitmap);
var clippingPath = reader.ClippingPaths[0];
clippingPath.ApplyTransform(crop.GetPathTransformMatrix(bitmap.Width, bitmap.Height).ToGdiPlusMatrix());
var adobeResources = new AdobeResourceDictionary();
adobeResources.Add(FirstPathId, new AdobeResourceBlock("Apple", clippingPath.Data));
var jpegSettings = new JpegSettings();
jpegSettings.AdobeResources = adobeResources;
cropped.Save("ModifyClippingPathExplicitly.jpg", jpegSettings);
}
Input
Apple.jpg
Output
ModifyClippingPathExplicitly.jpg
Used APIs
- Aurigma.GraphicsMill.Codecs.AdobeResourceBlock
- Aurigma.GraphicsMill.Codecs.AdobeResourceDictionary
- Aurigma.GraphicsMill.Codecs.ClippingPath.Path.ApplyTransform(Matrix)
- Aurigma.GraphicsMill.Codecs.ClippingPath.Path.Data
- Aurigma.GraphicsMill.Codecs.Frame.GetBitmap
- Aurigma.GraphicsMill.Codecs.ImageReader.ClippingPaths
- Aurigma.GraphicsMill.Codecs.ImageReader.Frames
- Aurigma.GraphicsMill.Codecs.JpegReader
- Aurigma.GraphicsMill.Codecs.JpegSettings
- Aurigma.GraphicsMill.Codecs.JpegSettings.AdobeResources
- Aurigma.GraphicsMill.Codecs.MetadataDictionary.Add(Object,Object)
- Aurigma.GraphicsMill.Transforms.Crop
- Aurigma.GraphicsMill.Transforms.Matrix.ToGdiPlusMatrix
- Aurigma.GraphicsMill.Transforms.Transform.Apply(Bitmap)
- Aurigma.GraphicsMill.Transforms.Transform.GetPathTransformMatrix(Int32,Int32)