public bool Convert (FilterRequest req) { string source = req.Current.LocalPath; Uri dest = req.TempUri (Path.GetExtension (source)); using (ImageFile img = ImageFile.Create (source)) { using (Pixbuf pixbuf = img.Load ()) { using (ImageInfo info = new ImageInfo (pixbuf)) { MemorySurface surface = new MemorySurface (Format.Argb32, pixbuf.Width, pixbuf.Height); Context ctx = new Context (surface); ctx.Matrix = info.Fill (info.Bounds, angle); Pattern p = new SurfacePattern (info.Surface); ctx.Source = p; ctx.Paint (); ((IDisposable)ctx).Dispose (); p.Destroy (); using (Pixbuf result = CairoUtils.CreatePixbuf (surface)) { using (Stream output = File.OpenWrite (dest.LocalPath)) { img.Save (result, output); } } surface.Flush (); info.Dispose (); req.Current = dest; return true; } } } }
public ImageInfo(ImageInfo info, Gdk.Rectangle allocation) { #if false Surface = new ImageSurface (Format.RGB24, allocation.Width, allocation.Height); Context ctx = new Context (Surface); #else Console.WriteLine ("source status = {0}", info.Surface.Status); Surface = info.Surface.CreateSimilar (Content.Color, allocation.Width, allocation.Height); System.Console.WriteLine ("status = {1} pointer = {0}", Surface.Handle.ToString (), Surface.Status); Context ctx = new Context (Surface); #endif Bounds = allocation; ctx.Matrix = info.Fill (allocation); Pattern p = new SurfacePattern (info.Surface); ctx.Source = p; ctx.Paint (); ((IDisposable)ctx).Dispose (); p.Destroy (); }
private ImageInfo CreateBlur (ImageInfo source) { double scale = Math.Max (256 / (double) source.Bounds.Width, 256 / (double) source.Bounds.Height); Gdk.Rectangle small = new Gdk.Rectangle (0, 0, (int) Math.Ceiling (source.Bounds.Width * scale), (int) Math.Ceiling (source.Bounds.Height * scale)); MemorySurface image = new MemorySurface (Format.Argb32, small.Width, small.Height); Context ctx = new Context (image); //Pattern solid = new SolidPattern (0, 0, 0, 0); //ctx.Source = solid; //ctx.Paint (); //solid.Destroy (); ctx.Matrix = source.Fit (small); ctx.Operator = Operator.Source; Pattern p = new SurfacePattern (source.Surface); ctx.Source = p; //Log.Debug (small); ctx.Paint (); p.Destroy (); ((IDisposable)ctx).Dispose (); Gdk.Pixbuf normal = MemorySurface.CreatePixbuf (image); Gdk.Pixbuf blur = PixbufUtils.Blur (normal, 3); ImageInfo overlay = new ImageInfo (blur); blur.Dispose (); normal.Dispose (); image.Destroy (); return overlay; }
public bool OnEvent(Widget w) { Gdk.Rectangle viewport = w.Allocation; if (buffer == null) { double scale = Math.Max (viewport.Width / (double) info.Bounds.Width, viewport.Height / (double) info.Bounds.Height); scale *= 1.2; buffer = new ImageInfo (info, w, new Gdk.Rectangle (0, 0, (int) (info.Bounds.Width * scale), (int) (info.Bounds.Height * scale))); start = DateTime.UtcNow; //w.QueueDraw (); zoom = 1.0; } double percent = Math.Min ((DateTime.UtcNow - start).Ticks / (double) duration.Ticks, 1.0); int n_x = (int) Math.Floor ((buffer.Bounds.Width - viewport.Width) * percent); int n_y = (int) Math.Floor ((buffer.Bounds.Height - viewport.Height) * percent); if (n_x != pan_x || n_y != pan_y) { //w.GdkWindow.Scroll (- (n_x - pan_x), - (n_y - pan_y)); w.QueueDraw (); w.GdkWindow.ProcessUpdates (false); Console.WriteLine ("{0} {1} elapsed", DateTime.UtcNow, DateTime.UtcNow - start); } pan_x = n_x; pan_y = n_y; return percent < 1.0; }
public SoftFocus(ImageInfo info) { this.info = info; center.X = info.Bounds.Width / 2; center.Y = info.Bounds.Height / 2; Amount = 3; Radius = .5; }
public ImageDisplay(BrowsablePointer item) { this.item = item; CanFocus = true; current = new ImageInfo (item.Current.DefaultVersionUri); if (item.Collection.Count > item.Index + 1) { next = new ImageInfo (item.Collection [item.Index + 1].DefaultVersionUri); } delay = new Delay (30, new GLib.IdleHandler (DrawFrame)); }
public ImageInfo(ImageInfo info, Widget w, Gdk.Rectangle bounds) { Cairo.Surface similar = CairoUtils.CreateSurface (w.GdkWindow); Bounds = bounds; Surface = similar.CreateSimilar (Content.ColorAlpha, Bounds.Width, Bounds.Height); Context ctx = new Context (Surface); ctx.Matrix = info.Fill (Bounds); Pattern p = new SurfacePattern (info.Surface); ctx.Source = p; ctx.Paint (); ((IDisposable)ctx).Dispose (); p.Destroy (); }
public ImageInfo(ImageInfo info, Widget w, Gdk.Rectangle bounds) { using (var similar = CairoUtils.CreateSurface (w.GdkWindow)) { Bounds = bounds; Surface = similar.CreateSimilar (Content.ColorAlpha, Bounds.Width, Bounds.Height); var ctx = new Context (Surface); ctx.Matrix = info.Fill (Bounds); Pattern p = new SurfacePattern (info.Surface); ctx.SetSource (p); ctx.Paint (); ctx.Dispose (); p.Dispose (); } }
public bool OnEvent (Widget w) { if (begin_buffer == null) { begin_buffer = new ImageInfo (begin, w); //.Allocation); } if (end_buffer == null) { end_buffer = new ImageInfo (end, w); //.Allocation); } w.QueueDraw (); w.GdkWindow.ProcessUpdates (false); TimeSpan elapsed = DateTime.UtcNow - start; double fraction = elapsed.Ticks / (double) duration.Ticks; return fraction < 1.0; }
private Pixbuf ProcessImpl (Pixbuf input, Cms.Profile input_profile, bool fast) { Pixbuf result; using (ImageInfo info = new ImageInfo (input)) { Widgets.SoftFocus soft = new Widgets.SoftFocus (info); soft.Radius = radius; MemorySurface surface = new MemorySurface (Format.Argb32, input.Width, input.Height); Context ctx = new Context (surface); soft.Apply (ctx, info.Bounds); ((IDisposable)ctx).Dispose (); result = MemorySurface.CreatePixbuf (surface); surface.Flush (); } return result; }
protected override void OnDestroyed () { if (current != null) { current.Dispose (); current = null; } if (next != null) { next.Dispose (); next = null; } Transition = null; if (effect != null) effect.Dispose (); base.OnDestroyed (); }
public bool OnEvent(Widget w) { if (begin_buffer == null) { begin_buffer = new ImageInfo (begin, w); //.Allocation); } if (end_buffer == null) { end_buffer = new ImageInfo (end, w); //.Allocation); start = DateTime.UtcNow; } w.QueueDraw (); TimeSpan elapsed = DateTime.UtcNow - start; fraction = elapsed.Ticks / (double) duration.Ticks; frames++; return fraction < 1.0; }
private Pixbuf ProcessImpl (Pixbuf input, Cms.Profile input_profile, bool fast) { Pixbuf result; using (ImageInfo info = new ImageInfo (input)) { MemorySurface surface = new MemorySurface (Format.Argb32, input.Width, input.Height); Context ctx = new Context (surface); ctx.Matrix = info.Fill (info.Bounds, angle); SurfacePattern p = new SurfacePattern (info.Surface); if (fast) { p.Filter = Filter.Fast; } ctx.Source = p; ctx.Paint (); ((IDisposable)ctx).Dispose (); p.Destroy (); result = MemorySurface.CreatePixbuf (surface); surface.Flush (); } return result; }
private Pixbuf ProcessImpl(Pixbuf input, Cms.Profile input_profile, bool fast) { Pixbuf result; using (ImageInfo info = new ImageInfo (input)) { using (MemorySurface surface = new MemorySurface (Format.Argb32, input.Width, input.Height)) { using (Context ctx = new Context (surface)) { ctx.Matrix = info.Fill (info.Bounds, angle); using (SurfacePattern p = new SurfacePattern (info.Surface)) { if (fast) p.Filter = Filter.Fast; ctx.Source = p; ctx.Paint (); } result = MemorySurface.CreatePixbuf (surface); surface.Flush (); } } } return result; }
public Dissolve (ImageInfo begin, ImageInfo end) { this.begin = begin; this.end = end; }
public Tilt(ImageInfo info) { this.info = info; }
ImageInfo CreateBlur(ImageInfo source) { double scale = Math.Max (256 / (double)source.Bounds.Width, 256 / (double)source.Bounds.Height); var small = new Gdk.Rectangle (0, 0, (int)Math.Ceiling (source.Bounds.Width * scale), (int)Math.Ceiling (source.Bounds.Height * scale)); var image = new ImageSurface (Format.Argb32, small.Width, small.Height); var ctx = new Context (image); ctx.Matrix = source.Fit (small); ctx.Operator = Operator.Source; Pattern p = new SurfacePattern (source.Surface); ctx.SetSource (p); ctx.Paint (); p.Dispose (); ctx.Dispose (); ImageInfo overlay = null; using (var normal = image.ToPixbuf ()) { using (var pixbufBlur = PixbufUtils.Blur (normal, 3, null)) { overlay = new ImageInfo (pixbufBlur); } } image.Dispose (); return overlay; }
public Reveal(ImageInfo begin, ImageInfo end) { this.begin = begin; this.end = end; }
private void UpdateSingle () { ImageInfo info; Photo photo = Photos[0]; histogram_expander.Visible = true; UpdateHistogram (); name_label.Visible = true; name_value_label.Text = photo.Name != null ? System.Uri.UnescapeDataString(photo.Name) : String.Empty; try { //using (new Timer ("building info")) { using (ImageFile img = ImageFile.Create (photo.DefaultVersionUri)) { info = new ImageInfo (img); } //} } catch (System.Exception e) { Log.Debug (e.StackTrace); info = new ImageInfo (null); } exposure_value_label.Text = info.ExposureInfo; if (exposure_value_label.Text.IndexOf (Environment.NewLine) != -1) exposure_label.Markup = default_exposure_string + Environment.NewLine; else exposure_label.Markup = default_exposure_string; exposure_label.Visible = true; exposure_value_label.Visible = true; size_value_label.Text = info.Dimensions; size_label.Visible = true; size_value_label.Visible = true; #if USE_EXIF_DATE date_value_label.Text = info.Date; #else DateTime local_time = photo.Time.ToLocalTime (); date_value_label.Text = String.Format ("{0}{2}{1}", local_time.ToShortDateString (), local_time.ToShortTimeString (), Environment.NewLine ); #endif version_label.Visible = true; version_option_menu.Visible = true; PhotoVersionMenu menu = new PhotoVersionMenu (photo); menu.VersionIdChanged += new PhotoVersionMenu.VersionIdChangedHandler (HandleVersionIdChanged); menu.WidthRequest = version_option_menu.Allocation.Width; version_option_menu.Menu = menu; uint i = 0; foreach (uint version_id in photo.VersionIds) { if (version_id == photo.DefaultVersionId) { // FIXME GTK# why not just .History = i ? version_option_menu.SetHistory (i); break; } i++; } if (show_tags) tag_view.Current = photo; rating_label.Visible = show_rating; rating_view.Visible = show_rating; if (show_rating) { rating_view.Value = (int) photo.Rating; } Show (); }
private Pixbuf ProcessImpl(Pixbuf input, Cms.Profile input_profile, bool fast) { Pixbuf result; using (ImageInfo info = new ImageInfo (input)) { using (Widgets.SoftFocus soft = new Widgets.SoftFocus (info)) { soft.Radius = radius; using (ImageSurface surface = new ImageSurface (Format.Argb32, input.Width, input.Height)) { using (Context ctx = new Context (surface)) { soft.Apply (ctx, info.Bounds); } result = surface.ToPixbuf(); surface.Flush (); } } } return result; }
public PanZoom(ImageInfo info) { this.info = info; }
protected virtual void Dispose(bool disposing) { if (disposed) return; disposed = true; if (disposing) { // free managed resources if (mask != null) { mask.Dispose (); mask = null; } if (blur != null) { blur.Dispose (); blur = null; } } // free unmanaged resources }
private void UpdateSingle() { ImageInfo info; Photo photo = Photos[0]; histogram_expander.Visible = true; UpdateHistogram (); if (show_name) { name_value_label.Text = photo.Name != null ? photo.Name : String.Empty; } name_label.Visible = show_name; name_value_label.Visible = show_name; try { //using (new Timer ("building info")) { using (ImageFile img = ImageFile.Create (photo.DefaultVersionUri)) { info = new ImageInfo (img); } //} } catch (System.Exception e) { FSpot.Utils.Log.Debug (e.StackTrace); info = new ImageInfo (null); } if (show_exposure) { exposure_value_label.Text = info.ExposureInfo; if (exposure_value_label.Text.IndexOf (Environment.NewLine) != -1) exposure_label.Markup = default_exposure_string + Environment.NewLine; else exposure_label.Markup = default_exposure_string; } exposure_label.Visible = show_exposure; exposure_value_label.Visible = show_exposure; if (show_size) size_value_label.Text = info.Dimensions; size_label.Visible = show_size; size_value_label.Visible = show_size; if (show_date) { #if USE_EXIF_DATE date_value_label.Text = info.Date; #else DateTime local_time = photo.Time; date_value_label.Text = String.Format ("{0}{2}{1}", local_time.ToShortDateString (), local_time.ToShortTimeString (), Environment.NewLine ); #endif } date_label.Visible = show_date; date_value_label.Visible = show_date; if (show_focal_length) focal_length_value_label.Text = info.FocalLength; focal_length_label.Visible = show_focal_length; focal_length_value_label.Visible = show_focal_length; if (show_camera) camera_value_label.Text = info.CameraModel; camera_label.Visible = show_camera; camera_value_label.Visible = show_camera; version_label.Visible = true; version_combo.Visible = true; version_list.Clear (); version_combo.Changed -= OnVersionComboChanged; bool hasVersions = photo.VersionIds.Length > 1; version_combo.Sensitive = hasVersions; if (hasVersions) { int i = 0; foreach (uint version_id in photo.VersionIds) { version_list.AppendValues (version_id, (photo.GetVersion (version_id) as PhotoVersion).Name, true); if (version_id == photo.DefaultVersionId) version_combo.Active = i; i++; } version_combo.TooltipText = String.Format (Catalog.GetPluralString ("(One Edit)", "({0} Edits)", i - 1), i - 1); } else { version_list.AppendValues (photo.DefaultVersionId, photo.DefaultVersion.Name + " " + Catalog.GetString ("(No Edits)"), true); version_combo.Active = 0; version_combo.TooltipText = Catalog.GetString ("(No Edits)"); } version_combo.Changed += OnVersionComboChanged; if (show_file_size) { try { GFile file = FileFactory.NewForUri (photo.DefaultVersionUri); GFileInfo file_info = file.QueryInfo ("standard::size", FileQueryInfoFlags.None, null); file_size_value_label.Text = Format.SizeForDisplay (file_info.Size); } catch (GLib.GException e) { file_size_value_label.Text = Catalog.GetString("(File read error)"); FSpot.Utils.Log.DebugException (e); } } file_size_label.Visible = show_file_size; file_size_value_label.Visible = show_file_size; if (show_tags) tag_view.Current = photo; rating_label.Visible = show_rating; rating_view.Visible = show_rating; if (show_rating) { rating_view.Value = (int) photo.Rating; } Show (); }
public Wipe(ImageInfo begin, ImageInfo end) { this.begin = begin; this.end = end; }
public void Dispose () { if (begin_buffer != null) { begin_buffer.Dispose (); begin_buffer = null; } if (end_buffer != null) { end_buffer.Dispose (); end_buffer = null; } }
public ImageInfo(ImageInfo info, Gdk.Rectangle allocation) { Surface = info.Surface.CreateSimilar (Content.Color, allocation.Width, allocation.Height); var ctx = new Context (Surface); Bounds = allocation; ctx.Matrix = info.Fill (allocation); Pattern p = new SurfacePattern (info.Surface); ctx.SetSource (p); ctx.Paint (); ctx.Dispose (); p.Dispose (); }
public ImageInfo(ImageInfo info, Widget w) : this(info, w, w.Allocation) { }