bma#30829
Hello,
Is it possible to adapth the clipping path when rotating or cropping an image with bitmap? I've tried with the pipeline and it worked, however when I try with bitmap, the clipping path doesn't adapt.
Code snippet working (pipeline):
Code snippet not working (bitmap):
Thank you in advance,
Kind regards
Is it possible to adapth the clipping path when rotating or cropping an image with bitmap? I've tried with the pipeline and it worked, however when I try with bitmap, the clipping path doesn't adapt.
Code snippet working (pipeline):
public byte[] Test(byte[] media)
{
using (var imageStream = new MemoryStream(media))
using (var exportedImageStream = new MemoryStream())
using (var reader = new JpegReader(imageStream))
using (var writer = new JpegWriter(exportedImageStream))
using (var rotate = new Rotate(60f))
using (var crop = new Crop(reader.Width / 2, 0, reader.Width / 2, reader.Height / 2))
{
writer.AdobeResources = reader.AdobeResources;
Pipeline.Run(reader + rotate + crop + writer);
return exportedImageStream.GetBuffer();
}
}Code snippet not working (bitmap):
public byte[] Test(byte[] media, int width, int height)
{
using (var imageStream = new MemoryStream(media))
using (var exportedImageStream = new MemoryStream())
using (var imageReader = ImageReader.Create(imageStream))
using (var bitmap = imageReader.Frames[0].GetBitmap())
{
var jpegSettings = new JpegSettings { Quality = 100 };
#region metadata
if (imageReader.AdobeResources != null)
{
jpegSettings.AdobeResources = imageReader.AdobeResources;
}
if (imageReader.Exif != null)
{
jpegSettings.Exif = imageReader.Exif;
}
if (imageReader.Iptc != null)
{
jpegSettings.Iptc = imageReader.Iptc;
}
if (imageReader.Xmp != null)
{
jpegSettings.Xmp = imageReader.Xmp;
}
#endregion
bitmap.Transforms.Resize(width, height);
bitmap.Transforms.Crop(imageReader.Width / 2, 0, imageReader.Width / 2, imageReader.Height / 2);
bitmap.Transforms.Rotate(30f);
bitmap.Save(exportedImageStream, jpegSettings);
return exportedImageStream.GetBuffer();
}
}Thank you in advance,
Kind regards