public static unsafe void ColorAdjust(Pixbuf src, Pixbuf dest, double brightness, double contrast, double hue, double saturation, int src_color, int dest_color) { if (src.Width != dest.Width || src.Height != dest.Height) { throw new Exception("Invalid Dimensions"); } //Cms.Profile eos10d = new Cms.Profile ("/home/lewing/ICCProfiles/EOS-10D-True-Color-Non-Linear.icm"); Cms.Profile srgb = Cms.Profile.CreateStandardRgb(); Cms.Profile bchsw = Cms.Profile.CreateAbstract(256, 0.0, brightness, contrast, hue, saturation, src_color, dest_color); Cms.Profile [] list = new Cms.Profile [] { srgb, bchsw, srgb }; Cms.Transform trans = new Cms.Transform(list, PixbufCmsFormat(src), PixbufCmsFormat(dest), Cms.Intent.Perceptual, 0x0100); ColorAdjust(src, dest, trans); trans.Dispose(); srgb.Dispose(); bchsw.Dispose(); }
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) { Gdk.Pixbuf input_copy = (Gdk.Pixbuf)Input.Clone(); 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_copy); alpha.Dispose(); final.Dispose(); final = input_copy; } else { Cms.Transform transform = new Cms.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; }
private void Adjust() { if (brightness_scale == null) { return; } if (AdjustedPixbuf == null) { return; } Cms.Profile display_profile = Cms.Profile.GetScreenProfile(view.Screen); Cms.Profile [] list; if (display_profile == null) { display_profile = Cms.Profile.CreateStandardRgb(); } if (!Changed || AdjustedPixbuf.HasAlpha) { if (AdjustedPixbuf.HasAlpha) { System.Console.WriteLine("Cannot currently adjust images with an alpha channel"); } list = new Cms.Profile [] { image_profile, display_profile }; next_transform = new Cms.Transform(list, PixbufUtils.PixbufCmsFormat(AdjustedPixbuf), PixbufUtils.PixbufCmsFormat(AdjustedPixbuf), Cms.Intent.Perceptual, 0x0000); } else { using (adjustment_profile = AdjustmentProfile()) { list = new Cms.Profile [] { image_profile, adjustment_profile, display_profile }; next_transform = new Cms.Transform(list, PixbufUtils.PixbufCmsFormat(AdjustedPixbuf), PixbufUtils.PixbufCmsFormat(AdjustedPixbuf), Cms.Intent.Perceptual, 0x0000); } } lock (AdjustedPixbuf) { PixbufUtils.ColorAdjust(ScaledPixbuf, AdjustedPixbuf, next_transform); #if USE_THREAD expose_timeout.Start(); #else this.QueueDraw(); #endif } }
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 (); }
public static unsafe void ColorAdjust(Gdk.Pixbuf src, Gdk.Pixbuf dest, Cms.Transform trans) { int width = src.Width; byte *srcpix = (byte *)src.Pixels; byte *destpix = (byte *)dest.Pixels; for (int row = 0; row < src.Height; row++) { trans.Apply((IntPtr)(srcpix + row * src.Rowstride), (IntPtr)(destpix + row * dest.Rowstride), (uint)width); } }
private void Adjust () { if (brightness_scale == null) return; if (AdjustedPixbuf == null) return; Cms.Profile display_profile = Cms.Profile.GetScreenProfile (view.Screen); Cms.Profile [] list; if (display_profile == null) display_profile = Cms.Profile.CreateStandardRgb (); if (!Changed || AdjustedPixbuf.HasAlpha) { if (AdjustedPixbuf.HasAlpha) System.Console.WriteLine ("Cannot currently adjust images with an alpha channel"); list = new Cms.Profile [] { image_profile, display_profile }; next_transform = new Cms.Transform (list, PixbufUtils.PixbufCmsFormat (AdjustedPixbuf), PixbufUtils.PixbufCmsFormat (AdjustedPixbuf), Cms.Intent.Perceptual, 0x0000); } else { using (adjustment_profile = AdjustmentProfile ()) { list = new Cms.Profile [] { image_profile, adjustment_profile, display_profile }; next_transform = new Cms.Transform (list, PixbufUtils.PixbufCmsFormat (AdjustedPixbuf), PixbufUtils.PixbufCmsFormat (AdjustedPixbuf), Cms.Intent.Perceptual, 0x0000); } } lock (AdjustedPixbuf) { PixbufUtils.ColorAdjust (ScaledPixbuf, AdjustedPixbuf, next_transform); #if USE_THREAD expose_timeout.Start (); #else this.QueueDraw (); #endif } }
public void Save () { if (!Changed) { this.Dialog.Destroy (); return; } if (!view.Item.IsValid) return; Console.WriteLine ("Saving...."); Photo photo = (Photo)view.Item.Current; try { bool create_version = photo.DefaultVersionId == Photo.OriginalVersionId; Gdk.Pixbuf orig = view.CompletePixbuf (); Gdk.Pixbuf final = new Gdk.Pixbuf (Gdk.Colorspace.Rgb, false, 8, orig.Width, orig.Height); Cms.Profile abs = AdjustmentProfile (); // FIXME this shouldn't use the screen as the destination profile. Cms.Profile destination = Cms.Profile.GetScreenProfile (view.Screen); if (destination == null) destination = Cms.Profile.CreateStandardRgb (); Cms.Profile [] list = new Cms.Profile [] { image_profile, abs, destination }; Cms.Transform transform = new Cms.Transform (list, PixbufUtils.PixbufCmsFormat (orig), PixbufUtils.PixbufCmsFormat (final), Cms.Intent.Perceptual, 0x0000); PixbufUtils.ColorAdjust (orig, final, transform); photo.SaveVersion (final, create_version); ((PhotoQuery)view.Query).Commit (view.Item.Index); final.Dispose (); } catch (System.Exception e) { string msg = Catalog.GetString ("Error saving adjusted photo"); string desc = String.Format (Catalog.GetString ("Received exception \"{0}\". Unable to save photo {1}"), e.Message, photo.Name); HigMessageDialog md = new HigMessageDialog ((Gtk.Window)Dialog.Toplevel, DialogFlags.DestroyWithParent, Gtk.MessageType.Error, ButtonsType.Ok, msg, desc); md.Run (); md.Destroy (); } this.Dialog.Sensitive = false; this.Dialog.Destroy (); }
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(); } }
public void Save() { if (!Changed) { this.Dialog.Destroy(); return; } if (!view.Item.IsValid) { return; } Console.WriteLine("Saving...."); Photo photo = (Photo)view.Item.Current; try { bool create_version = photo.DefaultVersionId == Photo.OriginalVersionId; Gdk.Pixbuf orig = view.CompletePixbuf(); Gdk.Pixbuf final = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, false, 8, orig.Width, orig.Height); Cms.Profile abs = AdjustmentProfile(); // FIXME this shouldn't use the screen as the destination profile. Cms.Profile destination = Cms.Profile.GetScreenProfile(view.Screen); if (destination == null) { destination = Cms.Profile.CreateStandardRgb(); } Cms.Profile [] list = new Cms.Profile [] { image_profile, abs, destination }; Cms.Transform transform = new Cms.Transform(list, PixbufUtils.PixbufCmsFormat(orig), PixbufUtils.PixbufCmsFormat(final), Cms.Intent.Perceptual, 0x0000); PixbufUtils.ColorAdjust(orig, final, transform); photo.SaveVersion(final, create_version); ((PhotoQuery)view.Query).Commit(view.Item.Index); final.Dispose(); } catch (System.Exception e) { string msg = Catalog.GetString("Error saving adjusted photo"); string desc = String.Format(Catalog.GetString("Received exception \"{0}\". Unable to save photo {1}"), e.Message, photo.Name); HigMessageDialog md = new HigMessageDialog((Gtk.Window)Dialog.Toplevel, DialogFlags.DestroyWithParent, Gtk.MessageType.Error, ButtonsType.Ok, msg, desc); md.Run(); md.Destroy(); } this.Dialog.Sensitive = false; this.Dialog.Destroy(); }