private static Eto.Drawing.Image PlatformGetDirectoryIcon(bool exists) { var icon = _theme.LoadIcon("folder", 16, 0); if (!exists) { icon = icon.Copy(); _iconMissing.Composite(icon, 8, 8, 8, 8, 8, 8, 0.5, 0.5, Gdk.InterpType.Tiles, 255); } return(new Bitmap(new BitmapHandler(icon))); }
protected override void LoadIcon(Gtk.Image image, int size) { base.LoadIcon(image, size); // Draw the F-Spot overlay if (size > 32 && Hit ["fspot:IsIndexed"] == "true") { Gdk.Pixbuf emblem = WidgetFu.LoadThemeIcon("f-spot", 24); Gdk.Pixbuf icon = image.Pixbuf.Copy(); if (icon == null || emblem == null) { return; } // FIXME: Ideally we'd composite into a fresh new pixbuf of // the correct size in this case, but really, who's going to // have images shorter or narrower than 16 pixels in f-spot?? if (icon.Height < emblem.Height || icon.Width < emblem.Width) { icon.Dispose(); emblem.Dispose(); return; } emblem.Composite(icon, 0, icon.Height - emblem.Height, emblem.Width, emblem.Height, 0, icon.Height - emblem.Height, 1, 1, Gdk.InterpType.Bilinear, 255); image.Pixbuf.Dispose(); image.Pixbuf = icon; } }
protected override void LoadIcon(Gtk.Image image, int size) { base.LoadIcon(image, size); string parent_mime_type = XdgMime.GetMimeTypeFromFileName(Hit.EscapedParentUri); if (parent_mime_type == null) { return; } Gdk.Pixbuf emblem = WidgetFu.LoadMimeIcon(parent_mime_type, 24); if (emblem == null) { return; } Gdk.Pixbuf icon = image.Pixbuf.Copy(); emblem.Composite(icon, 0, // dest_x icon.Height - emblem.Height, // dest_y emblem.Width, // dest_width emblem.Height, // dest_height 0, // offset_x icon.Height - emblem.Height, // offset_y 1, 1, // scale Gdk.InterpType.Bilinear, 255); image.Pixbuf.Dispose(); image.Pixbuf = icon; }
public override void BuildNode(ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) { ProjectFile file = (ProjectFile)dataObject; label = GLib.Markup.EscapeText(file.Link.IsNullOrEmpty ? file.FilePath.FileName : file.Link.FileName); if (!File.Exists(file.FilePath)) { label = "<span foreground='red'>" + label + "</span>"; } icon = DesktopService.GetPixbufForFile(file.FilePath, Gtk.IconSize.Menu); if (file.IsLink && icon != null) { icon = icon.Copy(); using (Gdk.Pixbuf overlay = Gdk.Pixbuf.LoadFromResource("Icons.16x16.LinkOverlay.png")) { overlay.Composite(icon, 0, 0, icon.Width, icon.Width, 0, 0, 1, 1, Gdk.InterpType.Bilinear, 255); } } }
void AddOverlay(ref Gdk.Pixbuf icon, Gdk.Pixbuf overlay) { Gdk.Pixbuf cached = Context.GetComposedIcon(icon, overlay); if (cached != null) { icon = cached; return; } int dx = 2; int dy = 2; Gdk.Pixbuf res = new Gdk.Pixbuf(icon.Colorspace, icon.HasAlpha, icon.BitsPerSample, icon.Width + dx, icon.Height + dy); res.Fill(0); icon.CopyArea(0, 0, icon.Width, icon.Height, res, 0, 0); overlay.Composite(res, res.Width - overlay.Width, res.Height - overlay.Height, overlay.Width, overlay.Height, res.Width - overlay.Width, res.Height - overlay.Height, 1, 1, Gdk.InterpType.Bilinear, 255); Context.CacheComposedIcon(icon, overlay, res); icon = res; }
private void HandleAreaPrepared(object sender, System.EventArgs args) { pixbuf = PixbufUtils.TransformOrientation(loader.Pixbuf, orientation, false); if (thumb != null && pixbuf != null) { thumb.Composite(pixbuf, 0, 0, pixbuf.Width, pixbuf.Height, 0.0, 0.0, pixbuf.Width / (double)thumb.Width, pixbuf.Height / (double)thumb.Height, Gdk.InterpType.Bilinear, 0xff); } if (thumb != null) { if (!ThumbnailGenerator.ThumbnailIsValid(thumb, uri)) { FSpot.ThumbnailGenerator.Default.Request(uri, 0, 256, 256); } } area_prepared = true; if (AreaUpdated != null) { AreaPrepared(this, new AreaPreparedArgs(false)); } if (thumb != null) { thumb.Dispose(); } thumb = null; }
//caller should check that sizes match public static Gdk.Pixbuf MergeIcons(Gdk.Pixbuf icon1, Gdk.Pixbuf icon2) { if (icon2 == null) { return(icon1); } if (icon1 == null) { return(icon2); } Gdk.Pixbuf res = new Gdk.Pixbuf(icon1.Colorspace, icon1.HasAlpha, icon1.BitsPerSample, icon1.Width, icon1.Height); res.Fill(0); icon1.CopyArea(0, 0, icon1.Width, icon1.Height, res, 0, 0); icon2.Composite(res, 0, 0, icon2.Width, icon2.Height, 0, 0, 1, 1, Gdk.InterpType.Bilinear, 255); var icon1_2x = Get2xIconVariant(icon1); var icon2_2x = Get2xIconVariant(icon2); if (icon1_2x != null || icon2_2x != null) { if (icon1_2x == null) { icon1_2x = ScaleIcon(icon1, icon1.Width * 2, icon1.Height * 2); } if (icon2_2x == null) { icon2_2x = ScaleIcon(icon2, icon2.Width * 2, icon2.Height * 2); } var res2x = MergeIcons(icon1_2x, icon2_2x); Set2xIconVariant(res, res2x); } return(res); }
//caller should check null and that sizes match static Gdk.Pixbuf MergeIcons(Gdk.Pixbuf icon1, Gdk.Pixbuf icon2) { Gdk.Pixbuf res = new Gdk.Pixbuf(icon1.Colorspace, icon1.HasAlpha, icon1.BitsPerSample, icon1.Width, icon1.Height); res.Fill(0); icon1.CopyArea(0, 0, icon1.Width, icon1.Height, res, 0, 0); icon2.Composite(res, 0, 0, icon2.Width, icon2.Height, 0, 0, 1, 1, Gdk.InterpType.Bilinear, 255); return(res); }
public static Gdk.Pixbuf FadeIcon(Gdk.Pixbuf source) { Gdk.Pixbuf result = source.Copy(); result.Fill(0); result = result.AddAlpha(true, 0, 0, 0); source.Composite(result, 0, 0, source.Width, source.Height, 0, 0, 1, 1, Gdk.InterpType.Bilinear, 128); return(result); }
public static Gdk.Pixbuf MakeTransparent(Gdk.Pixbuf icon, double opacity) { Gdk.Pixbuf result = icon.Copy(); result.Fill(0); result = result.AddAlpha(true, 0, 0, 0); icon.Composite(result, 0, 0, icon.Width, icon.Height, 0, 0, 1, 1, Gdk.InterpType.Bilinear, (int)(256 * opacity)); return(result); }
public static Gdk.Pixbuf AddIconOverlay(Gdk.Pixbuf target, Gdk.Pixbuf overlay) { Gdk.Pixbuf res = new Gdk.Pixbuf(target.Colorspace, target.HasAlpha, target.BitsPerSample, target.Width, target.Height); res.Fill(0); target.CopyArea(0, 0, target.Width, target.Height, res, 0, 0); overlay.Composite(res, 0, 0, overlay.Width, overlay.Height, 0, 0, 1, 1, Gdk.InterpType.Bilinear, 255); return(res); }
public override object ChangeOpacity(object backend, double opacity) { Gdk.Pixbuf image = (Gdk.Pixbuf)backend; Gdk.Pixbuf result = image.Copy(); result.Fill(0); result = result.AddAlpha(true, 0, 0, 0); image.Composite(result, 0, 0, image.Width, image.Height, 0, 0, 1, 1, Gdk.InterpType.Bilinear, (int)(255 * opacity)); return(result); }
public static Gdk.Pixbuf MakeTransparent(Gdk.Pixbuf icon, double opacity) { Gdk.Pixbuf result = icon.Copy(); result.Fill(0); result = result.AddAlpha(true, 0, 0, 0); icon.Composite(result, 0, 0, icon.Width, icon.Height, 0, 0, 1, 1, Gdk.InterpType.Bilinear, (int)(256 * opacity)); var icon2x = Get2xIconVariant(icon); if (icon2x != null) { Set2xIconVariant(result, MakeTransparent(icon2x, opacity)); } return(result); }
// public static void OnGtkIconThemeChanged(object o, EventArgs args) // { // lock(typeof(iFolderViewItem)) // { // // FIXME: Refresh the icons. // } // } public static Gdk.Pixbuf CreateEmblemedPixbuf(Gdk.Pixbuf icon, Gdk.Pixbuf emblem) { if (icon == null || emblem == null) { return(null); } if (icon.Width <= emblem.Width || icon.Height <= emblem.Height) { return(null); } Gdk.Pixbuf dest = new Gdk.Pixbuf(icon.Colorspace, true, icon.BitsPerSample, icon.Width, icon.Height); dest.Fill(0x00000000); // transparent try { icon.Composite(dest, 0, 0, dest.Width, dest.Height, 0, 0, 1.0, 1.0, Gdk.InterpType.Bilinear, 255); emblem.Composite(dest, icon.Width - emblem.Width - 1, icon.Height - emblem.Height - 1, emblem.Width, emblem.Height, icon.Width - emblem.Width - 1, icon.Height - emblem.Height - 1, 1.0, 1.0, Gdk.InterpType.Bilinear, 255); } catch (Exception) { dest = null; } return(dest); }
private static Xwt.Drawing.Image ToXwtImage(Gdk.Pixbuf icon) { Xwt.Drawing.Image ret; var icon2 = new Gdk.Pixbuf(icon.Colorspace, true, icon.BitsPerSample, icon.Width + 1, icon.Height); icon2.Fill(0); icon.Composite(icon2, 0, 0, icon.Width, icon.Height, 0, 0, 1, 1, Gdk.InterpType.Tiles, 255); using (var stream = new MemoryStream(icon2.SaveToBuffer("png"))) { stream.Position = 0; ret = Xwt.Drawing.Image.FromStream(stream); } return(ret); }
protected override void LoadIcon(Gtk.Image image, int size) { // The File tile doesn't respect the icon size because // 48 is too small for thumbnails if (!thumbnailer.SetThumbnailIcon(image, Hit, size)) { base.LoadIcon(image, size); } // FIXME: Multiple emblems string emblem = Hit.GetFirstProperty("nautilus:emblem"); if (String.IsNullOrEmpty(emblem)) { return; } Gdk.Pixbuf emblem_pixbuf = WidgetFu.LoadThemeIcon("emblem-" + emblem, 24); if (emblem_pixbuf == null) { return; } Gdk.Pixbuf icon = image.Pixbuf.Copy(); // If the icon itself is smaller than our requested // emblem, just display the icon. if ((icon.Height < emblem_pixbuf.Height || icon.Width < emblem_pixbuf.Width) || (icon.Height < (emblem_pixbuf.Height * 2) && icon.Width < (emblem_pixbuf.Width * 2))) { icon.Dispose(); emblem_pixbuf.Dispose(); return; } emblem_pixbuf.Composite(icon, 0, 0, emblem_pixbuf.Width, emblem_pixbuf.Height, 0, 0, 1, 1, Gdk.InterpType.Bilinear, 255); emblem_pixbuf.Dispose(); image.Pixbuf.Dispose(); image.Pixbuf = icon; }
// requires: target contains non-empty image // effects: applies the operations to _original and composes it onto the given target; // does not modify _original public void Apply(Gdk.Pixbuf target) { int layerWidth = (int)(Size * _original.Width); int layerHeight = (int)(Size * _original.Height); if (layerWidth > target.Width || layerHeight > target.Height) { Console.WriteLine("ERROR: Layer too large....aborting"); return; } int startx = (int)(X - layerWidth / 2); int starty = (int)(Y - layerHeight / 2); int width = (int)(_original.Width * Size); int height = (int)(_original.Height * Size); startx = Math.Clamp(startx, 0, target.Width - layerWidth); starty = Math.Clamp(starty, 0, target.Height - layerHeight); _original.Composite(target, startx, starty, width, height, startx, starty, Size, Size, Gdk.InterpType.Nearest, 255); }
public void Paint(Gdk.Pixbuf pb, DateTime now) { if (!initialized_current_x) { initialized_current_x = true; if (direction == Direction.FromLeft) { current_x = -1 * pb.Width; } else { current_x = pb.Width * 2; } } if (current_x == eventual_x) { painter(pb, now); RaiseDoneSwooshing(); return; } if (sub_pixbuf == null) { CreateSubPixbuf(pb); } sub_pixbuf.Fill(0x000000); /* first off call the subpainter to update our display */ painter(sub_pixbuf, now); if (last == DateTime.MinValue) { last = now; } /* then move ourselves if we need to */ delta_to_change -= now - last; if (delta_to_change < TimeSpan.Zero) { if (direction == Direction.FromLeft) { current_x += delta_x; if (current_x > eventual_x) { current_x = eventual_x; } } else { current_x -= delta_x; if (current_x < eventual_x) { current_x = eventual_x; } } delta_to_change = TimeSpan.FromMilliseconds(50); } last = now; /* then composite our entire pixbuf on the root pb */ if (current_x < 0) { if (current_x + sub_pixbuf.Width <= 0) { return; } sub_pixbuf.Composite(pb, 0, y, sub_pixbuf.Width + current_x, sub_pixbuf.Height, current_x, y, 1, 1, InterpType.Nearest, alpha); } else if (current_x + sub_pixbuf.Width >= pb.Width) { if (current_x > pb.Width) { return; } sub_pixbuf.Composite(pb, current_x, y, pb.Width - current_x, sub_pixbuf.Height, current_x, y, 1, 1, InterpType.Nearest, alpha); } else { sub_pixbuf.Composite(pb, current_x, y, sub_pixbuf.Width, sub_pixbuf.Height, current_x, y, 1, 1, InterpType.Nearest, alpha); } }