public Pixbuf Adjust() { var final = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, false, 8, Input.Width, Input.Height); Profile[] list = GenerateAdjustments().ToArray(); if (Input.HasAlpha) { var inputCopy = (Gdk.Pixbuf)Input.Clone(); var alpha = PixbufUtils.Flatten(Input); var transform = new Transform(list, PixbufUtils.PixbufCmsFormat(alpha), PixbufUtils.PixbufCmsFormat(final), intent, 0x0000); PixbufUtils.ColorAdjust(alpha, final, transform); PixbufUtils.ReplaceColor(final, inputCopy); alpha.Dispose(); final.Dispose(); final = inputCopy; } else { var transform = new Transform(list, PixbufUtils.PixbufCmsFormat(Input), PixbufUtils.PixbufCmsFormat(final), intent, 0x0000); PixbufUtils.ColorAdjust(Input, final, transform); } return(final); }
public Pixbuf Adjust() { Gdk.Pixbuf final = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, false, 8, Input.Width, Input.Height); Cms.Profile [] list = GenerateAdjustments().ToArray(); if (Input.HasAlpha) { Pixbuf alpha = PixbufUtils.Flatten(Input); Transform transform = new Transform(list, PixbufUtils.PixbufCmsFormat(alpha), PixbufUtils.PixbufCmsFormat(final), intent, 0x0000); PixbufUtils.ColorAdjust(alpha, final, transform); PixbufUtils.ReplaceColor(final, Input); alpha.Dispose(); final.Dispose(); final = Input; } else { Cms.Transform transform = new Cms.Transform(list, PixbufUtils.PixbufCmsFormat(Input), PixbufUtils.PixbufCmsFormat(final), intent, 0x0000); PixbufUtils.ColorAdjust(Input, final, transform); } return(final); }
public bool Convert(FilterRequest req) { Uri source = req.Current; using (ImageFile img = ImageFile.Create(source)) { pixbuf = img.Load(); profile = img.GetProfile(); // If the image doesn't have an embedded profile assume it is sRGB if (profile == null) { profile = Profile.CreateStandardRgb(); } if (destination == null) { destination = profile; } Gdk.Pixbuf final = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, false, 8, pixbuf.Width, pixbuf.Height); Profile [] list = Prepare(pixbuf); if (pixbuf.HasAlpha) { Gdk.Pixbuf alpha = PixbufUtils.Flatten(pixbuf); Transform transform = new Transform(list, PixbufUtils.PixbufCmsFormat(alpha), PixbufUtils.PixbufCmsFormat(final), rendering_intent, 0x0000); PixbufUtils.ColorAdjust(alpha, final, transform); PixbufUtils.ReplaceColor(final, pixbuf); alpha.Dispose(); final.Dispose(); final = pixbuf; } else { Transform transform = new Transform(list, PixbufUtils.PixbufCmsFormat(pixbuf), PixbufUtils.PixbufCmsFormat(final), rendering_intent, 0x0000); PixbufUtils.ColorAdjust(pixbuf, final, transform); pixbuf.Dispose(); } Uri dest_uri = req.TempUri(Path.GetExtension(source.LocalPath)); using (Stream output = File.OpenWrite(dest_uri.LocalPath)) { img.Save(final, output); } final.Dispose(); req.Current = dest_uri; return(true); } }
public void Adjust() { bool create_version = photo.DefaultVersionId == Photo.OriginalVersionId; using (ImageFile img = ImageFile.Create(photo.DefaultVersionUri)) { if (image == null) { image = img.Load(); } if (image_profile == null) { image_profile = img.GetProfile(); } } if (image_profile == null) { image_profile = Cms.Profile.CreateStandardRgb(); } if (destination_profile == null) { destination_profile = image_profile; } Gdk.Pixbuf final = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, false, 8, image.Width, image.Height); Cms.Profile adjustment_profile = GenerateProfile(); Cms.Profile [] list; if (adjustment_profile != null) { list = new Cms.Profile [] { image_profile, adjustment_profile, destination_profile } } ; else { list = new Cms.Profile [] { image_profile, destination_profile } }; if (image.HasAlpha) { Pixbuf alpha = PixbufUtils.Flatten(image); Transform transform = new Transform(list, PixbufUtils.PixbufCmsFormat(alpha), PixbufUtils.PixbufCmsFormat(final), intent, 0x0000); PixbufUtils.ColorAdjust(alpha, final, transform); PixbufUtils.ReplaceColor(final, image); alpha.Dispose(); final.Dispose(); final = image; } else { Cms.Transform transform = new Cms.Transform(list, PixbufUtils.PixbufCmsFormat(image), PixbufUtils.PixbufCmsFormat(final), intent, 0x0000); PixbufUtils.ColorAdjust(image, final, transform); image.Dispose(); } photo.SaveVersion(final, create_version); final.Dispose(); } }