private static Gdk.Pixbuf Scale(Gdk.Pixbuf pixbuf, int width, int height, out int widthPadding, out int heightPadding) { if (pixbuf.Width == width && pixbuf.Height == height) { widthPadding = 0; heightPadding = 0; return(pixbuf); } double scale = Math.Min(width / (double)pixbuf.Width, height / (double)pixbuf.Height); int scaleWidth = (int)(scale * pixbuf.Width); int scaleHeight = (int)(scale * pixbuf.Height); Gdk.Pixbuf scaled = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, false, 8, width, height); scaled.Fill(0); widthPadding = width - scaleWidth; heightPadding = height - scaleHeight; pixbuf.Scale(scaled, widthPadding / 2, heightPadding / 2, scaleWidth, scaleHeight, widthPadding / 2, heightPadding / 2, scale, scale, Gdk.InterpType.Bilinear); return(scaled); }
public static Gdk.Pixbuf DesaturateIcon(Gdk.Pixbuf source) { Gdk.Pixbuf dest = new Gdk.Pixbuf(source.Colorspace, source.HasAlpha, source.BitsPerSample, source.Width, source.Height); dest.Fill(0); source.SaturateAndPixelate(dest, 0, false); return(dest); }
/// <summary> /// Given a ProgramDescriptionViewModel, produce a single Gdk.Pixbuf that includes all of the program's feature icons. /// </summary> /// <param name="viewModel">View model of the program whose feature icons are to be rendered as a pixbuf.</param> /// <returns>A pixbuf containing the features.</returns> public static Gdk.Pixbuf ConvertToPixbuf(ProgramDescriptionViewModel viewModel) { // TODO: cache these so they don't need to be recreated all the time. Gdk.Pixbuf pixbuf = null; var features = viewModel.Features; var totWidth = System.Math.Max(0, Padding * (features.Count - 1)); var totHeight = 0; foreach (var f in features) { totWidth += f.Image.Size.Width; totHeight = System.Math.Max(totHeight, f.Image.Size.Height); } if (totWidth > 0) { Gdk.Pixbuf image = features[0].Image; pixbuf = new Gdk.Pixbuf(image.Colorspace, image.HasAlpha, image.BitsPerSample, totWidth, totHeight); pixbuf.Fill(0xFFFFFF00); // fill with transparent white (??) var x = 0; foreach (var f in features) { var imageSize = f.Image.Size; ((Gdk.Pixbuf)f.Image).CopyArea(0, 0, f.Image.Size.Width, f.Image.Size.Height, pixbuf, x, 0); x += Padding + f.Image.Size.Width; } } return(pixbuf); }
private bool DelayedUpdateHistogram() { if (Photos.Length == 0) { return(false); } IPhoto photo = Photos[0]; Gdk.Pixbuf hint = histogram_hint; histogram_hint = null; int max = histogram_expander.Allocation.Width; try { if (hint == null) { using (var img = ImageFile.Create(photo.DefaultVersion.Uri)) { hint = img.Load(256, 256); } } histogram_image.Pixbuf = histogram.Generate(hint, max); hint.Dispose(); } catch (System.Exception e) { Hyena.Log.Debug(e.StackTrace); using (Gdk.Pixbuf empty = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, true, 8, 256, 256)) { empty.Fill(0x0); histogram_image.Pixbuf = histogram.Generate(empty, max); } } return(false); }
public Gdk.Pixbuf GetIcon(Gdk.Color gcolor) { uint color = (((uint)gcolor.Red >> 8) << 24) | (((uint)gcolor.Green >> 8) << 16) | (((uint)gcolor.Blue >> 8) << 8) | 0xff; Gdk.Pixbuf icon = new Gdk.Pixbuf (Gdk.Colorspace.Rgb, true, 8, 16, 16); icon.Fill (color); return icon; }
public BlendDialog() { this.Build(); nodeview1.Model = ls; nodeview1.Selection.Mode = SelectionMode.Multiple; var iconRender = new CellRendererPixbuf(); var iconCol = new TreeViewColumn("Icon", iconRender); iconCol.PackStart(iconRender, true); iconCol.SetCellDataFunc(iconRender, new TreeCellDataFunc((tc, c, m, i) => { Gdk.Pixbuf buf = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, false, 8, 16, 16); buf.Fill(GetItemFromIter(i).ToGdkPixel()); ((CellRendererPixbuf)c).Pixbuf = buf; })); var colorRender = new CellRendererText(); var colorCol = new TreeViewColumn("Color", colorRender); colorCol.PackStart(colorRender, true); colorCol.SetCellDataFunc(colorRender, new TreeCellDataFunc((tc, c, m, i) => { ((CellRendererText)c).Text = GetItemFromIter(i).ToHtml(); })); nodeview1.AppendColumn(iconCol); nodeview1.AppendColumn(colorCol); }
public static Gdk.Pixbuf DesaturateIcon(Gdk.Pixbuf source) { Gdk.Pixbuf dest = new Gdk.Pixbuf (source.Colorspace, source.HasAlpha, source.BitsPerSample, source.Width, source.Height); dest.Fill (0); source.SaturateAndPixelate (dest, 0, false); return dest; }
//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); }
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; }
public Gdk.Pixbuf GetIcon(Gdk.Color gcolor) { uint color = (((uint)gcolor.Red >> 8) << 24) | (((uint)gcolor.Green >> 8) << 16) | (((uint)gcolor.Blue >> 8) << 8) | 0xff; Gdk.Pixbuf icon = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, true, 8, 16, 16); icon.Fill(color); return(icon); }
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 Crop(object handle, int srcX, int srcY, int width, int height) { var pix = (Gdk.Pixbuf)handle; Gdk.Pixbuf res = new Gdk.Pixbuf (pix.Colorspace, pix.HasAlpha, pix.BitsPerSample, width, height); res.Fill (0); pix.CopyArea (srcX, srcY, width, height, res, 0, 0); return res; }
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 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); }
//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 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 override object Crop(object handle, int srcX, int srcY, int width, int height) { var pix = (Gdk.Pixbuf)handle; Gdk.Pixbuf res = new Gdk.Pixbuf(pix.Colorspace, pix.HasAlpha, pix.BitsPerSample, width, height); res.Fill(0); pix.CopyArea(srcX, srcY, width, height, res, 0, 0); return(res); }
public override object CropBitmap(object handle, int srcX, int srcY, int width, int height) { var pix = ((GtkImage)handle).Frames[0].Pixbuf; Gdk.Pixbuf res = new Gdk.Pixbuf(pix.Colorspace, pix.HasAlpha, pix.BitsPerSample, width, height); res.Fill(0); pix.CopyArea(srcX, srcY, width, height, res, 0, 0); return(new GtkImage(res)); }
public RenameColorDialog(RgbColor c, string t, string title = "Rename") : this() { Gdk.Pixbuf buf = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, false, 8, 16, 16); buf.Fill(c.ToGdkPixel()); image1.Pixbuf = buf; colorLabel.Text = c.ToHtml(); textEntry.Text = t; Title = title; }
private static void PlatformInit() { Linux = true; _theme = IconTheme.Default; var linkIcon = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, true, 8, 16, 16); linkIcon.Fill(0x00000000); _theme.LoadIcon("emblem-symbolic-link", 16, 0).Composite(linkIcon, 8, 8, 8, 8, 8, 8, 0.5, 0.5, Gdk.InterpType.Tiles, 255); _files["0."] = ToEtoImage(_theme.LoadIcon("text-x-generic", 16, 0)); _folder = ToEtoImage(_theme.LoadIcon("folder", 16, 0)); _link = ToEtoImage(linkIcon); }
public static Gdk.Pixbuf GetIcon(this Counter c) { Gdk.Pixbuf cachedIcon; if (icons.TryGetValue(c, out cachedIcon)) { return(cachedIcon); } Gdk.Color gcolor = c.GetColor(); uint color = (((uint)gcolor.Red >> 8) << 24) | (((uint)gcolor.Green >> 8) << 16) | (((uint)gcolor.Blue >> 8) << 8) | 0xff; cachedIcon = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, true, 8, 16, 16); cachedIcon.Fill(color); icons [c] = cachedIcon; return(cachedIcon); }
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); }
static Gdk.Pixbuf CreateColorBlock(string name, Gtk.IconSize size) { int w, h; if (!Gtk.Icon.SizeLookup(Gtk.IconSize.Menu, out w, out h)) { w = h = 22; } Gdk.Pixbuf p = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, true, 8, w, h); uint color; if (!TryParseColourFromHex(name, false, out color)) { //if lookup fails, make it transparent color = 0xffffff00u; } p.Fill(color); return(p); }
bool DelayedUpdateHistogram() { if (Photos.Length == 0) { return(false); } var photo = Photos[0]; var hint = histogram_hint; histogram_hint = null; int max = histogram_expander.Allocation.Width; try { if (hint == null) { using (var img = App.Instance.Container.Resolve <IImageFileFactory>().Create(photo.DefaultVersion.Uri)) { // FIXME, ImageSharp var image = (Image <Rgba32>)img.Load(256, 256); //hint = new Gdk.Pixbuf(image); } } histogram_image.Pixbuf = histogram.Generate(hint, max); hint.Dispose(); } catch (Exception e) { Hyena.Log.Debug(e.StackTrace); using (var empty = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, true, 8, 256, 256)) { empty.Fill(0x0); histogram_image.Pixbuf = histogram.Generate(empty, max); } } return(false); }
private void InitializeColorComboBox(Gtk.ComboBox colorChooser, ObservableCollection <FileNodeColorViewModel> colors, MenuLayoutViewModel dataContext) { colorChooser.SetValue(IFakeDependencyObjectHelpers.DataContextPropertyName, dataContext); colorChooser.TooltipText = MenuLayoutViewModel.ColorTip; foreach (var color in colors) { var pixbufColor = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, true, 8, 14, 14); var uintColor = (uint)((color.Fill.Red & 0xFF) << 24) | (uint)((color.Fill.Green & 0xFF) << 16) | (uint)((color.Fill.Blue & 0xFF) << 8) | 0xFF; pixbufColor.Fill(uintColor); var pixbuf = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, true, 8, 16, 16); pixbuf.Fill(0xFF); // black background pixbufColor.CopyArea(0, 0, 14, 14, pixbuf, 1, 1); ColorPixbufs[color.IntvColor] = pixbuf; } Gtk.CellRenderer cellRenderer = new Gtk.CellRendererPixbuf() { Xalign = 0 }; colorChooser.PackStart(cellRenderer, false); colorChooser.SetCellDataFunc(cellRenderer, (l, e, m, i) => VisualHelpers.CellImageRenderer <FileNodeColorViewModel>(l, e, m, i, c => ColorPixbufs[c.IntvColor])); cellRenderer = new Gtk.CellRendererCombo() { Xalign = 0, Xpad = 4 }; colorChooser.PackEnd(cellRenderer, true); colorChooser.SetCellDataFunc(cellRenderer, (l, e, m, i) => VisualHelpers.CellTextRenderer <FileNodeColorViewModel>(l, e, m, i, c => c.Name)); var colorListStore = new Gtk.ListStore(typeof(FileNodeColorViewModel)); colorListStore.SynchronizeCollection(colors); colorChooser.Model = colorListStore; MenuLayoutCommandGroup.SetColorCommand.CanExecuteChanged += HandleCanExecuteSetColorChanged; }
static Gdk.Pixbuf CreateColorBlock (string name, Gtk.IconSize size) { int w, h; if (!Gtk.Icon.SizeLookup (Gtk.IconSize.Menu, out w, out h)) w = h = 22; Gdk.Pixbuf p = new Gdk.Pixbuf (Gdk.Colorspace.Rgb, true, 8, w, h); uint color; if (!TryParseColourFromHex (name, false, out color)) //if lookup fails, make it transparent color = 0xffffff00u; p.Fill (color); return p; }
public override object CropBitmap (object handle, int srcX, int srcY, int width, int height) { var pix = ((GtkImage)handle).Frames[0].Pixbuf; Gdk.Pixbuf res = new Gdk.Pixbuf (pix.Colorspace, pix.HasAlpha, pix.BitsPerSample, width, height); res.Fill (0); pix.CopyArea (srcX, srcY, width, height, res, 0, 0); return new GtkImage (res); }
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); } }
private static Gdk.Pixbuf Scale(Gdk.Pixbuf pixbuf, int width, int height, out int widthPadding, out int heightPadding) { if (pixbuf.Width == width && pixbuf.Height == height) { widthPadding = 0; heightPadding = 0; return pixbuf; } double scale = Math.Min (width / (double) pixbuf.Width, height / (double) pixbuf.Height); int scaleWidth = (int) (scale * pixbuf.Width); int scaleHeight = (int) (scale * pixbuf.Height); Gdk.Pixbuf scaled = new Gdk.Pixbuf (Gdk.Colorspace.Rgb, false, 8, width, height); scaled.Fill (0); widthPadding = width - scaleWidth; heightPadding = height - scaleHeight; pixbuf.Scale (scaled, widthPadding / 2, heightPadding / 2, scaleWidth, scaleHeight, widthPadding / 2, heightPadding / 2, scale, scale, Gdk.InterpType.Bilinear); return scaled; }
private bool DelayedUpdateHistogram() { if (Photos.Length == 0) return false; IPhoto photo = Photos[0]; Gdk.Pixbuf hint = histogram_hint; histogram_hint = null; int max = histogram_expander.Allocation.Width; try { if (hint == null) using (var img = ImageFile.Create (photo.DefaultVersion.Uri)) { hint = img.Load (256, 256); } histogram_image.Pixbuf = histogram.Generate (hint, max); hint.Dispose (); } catch (System.Exception e) { Hyena.Log.Debug (e.StackTrace); using (Gdk.Pixbuf empty = new Gdk.Pixbuf (Gdk.Colorspace.Rgb, true, 8, 256, 256)) { empty.Fill (0x0); histogram_image.Pixbuf = histogram.Generate (empty, max); } } return false; }
/// <summary> /// Handles the start of processing of a new node. /// </summary> /// <param name="sender"> /// A <see cref="System.Object"/> /// </param> /// <param name="args"> /// A <see cref="EventArgs"/> /// </param> private void OnControllerTokenChecked(object sender, TokenCheckedArgs args) { Application.Invoke(sender, args, delegate(object resender, EventArgs _args) { TokenCheckedArgs a = _args as TokenCheckedArgs; if(!sequencingFinished) { currentToken = a.CurrentToken; FloatBitmap sequenceImage; if(a.LastSequence!= null) { TokenSequence joinSeq = new TokenSequence(a.LastSequence); lastToken = joinSeq.Last; joinSeq.Append(currentToken); Token joinedToken =Token.Join(joinSeq, ""); sequenceImage = joinedToken.Image; } else { sequenceImage = currentToken.Image; lastToken = null; } // We add a border to the orginal image. Gdk.Pixbuf sequencePixbuf = sequenceImage.CreatePixbuf(); Gdk.Pixbuf drawnImage = new Gdk.Pixbuf(sequencePixbuf.Colorspace,false, 8, sequencePixbuf.Width+10, sequencePixbuf.Height+10); drawnImage.Fill(0xFFFFFFFF); sequencePixbuf.CopyArea(0, 0, sequencePixbuf.Width, sequencePixbuf.Height, drawnImage, 5,5); if(lastToken!=null) { uint color; if(currentToken.CloseFollows(lastToken)) { color = 0x00FF00; sequencingStepResultLbl.Markup = String.Format("<b>Sí, el símbolo «{0}» se añadirá a la secuencia actual</b>", currentToken.Text); } else { color = 0xFF0000; sequencingStepResultLbl.Markup = String.Format("<b>No, «{0}» no puede ser considerado parte de la secuencia ({1})</b>", currentToken.Text, a.LastSequence.ToString()); } Gdk.Pixbuf markedImage = drawnImage.Copy(); // We paint the image of the color markedImage = markedImage.CompositeColorSimple(markedImage.Width, markedImage.Height, Gdk.InterpType.Nearest, 100, 1, color, color); // We are going to mark the image of the to symbols being considered // with their baselines. int min = int.MaxValue; foreach (Token t in a.LastSequence ) { if(t.Top < min) min =t.Top; } int offset = Math.Min(min, currentToken.Top); int lastBaseline = lastToken.Baseline - offset; int currentBaseline = currentToken.Baseline - offset; markedImage.CopyArea(0, lastBaseline, markedImage.Width, 5, drawnImage, 0,lastBaseline); markedImage.CopyArea(0, currentBaseline, markedImage.Width,5, drawnImage, 0,currentBaseline); } baselineImageArea.Image = drawnImage; } if(controller.StepMode == ControllerStepMode.StepByStep) tokenizingNextButtonsAlign.Sensitive = true; }); }
public SlideShow (string name) { Tag tag; if (name != null) tag = Database.Tags.GetTagByName (name); else { int id = (int) Preferences.Get (Preferences.SCREENSAVER_TAG); tag = Database.Tags.GetTagById (id); } Photo [] photos; if (tag != null) photos = Database.Photos.Query (new Tag [] { tag } ); else if ((int) Preferences.Get (Preferences.SCREENSAVER_TAG) == 0) photos = db.Photos.Query (new Tag [] {}); else photos = new Photo [0]; window = new XScreenSaverSlide (); SetStyle (window); if (photos.Length > 0) { Array.Sort (photos, new Photo.RandomSort ()); Gdk.Pixbuf black = new Gdk.Pixbuf (Gdk.Colorspace.Rgb, false, 8, 1, 1); black.Fill (0x00000000); slideview = new SlideView (black, photos); window.Add (slideview); } else { Gtk.HBox outer = new Gtk.HBox (); Gtk.HBox hbox = new Gtk.HBox (); Gtk.VBox vbox = new Gtk.VBox (); outer.PackStart (new Gtk.Label (String.Empty)); outer.PackStart (vbox, false, false, 0); vbox.PackStart (new Gtk.Label (String.Empty)); vbox.PackStart (hbox, false, false, 0); hbox.PackStart (new Gtk.Image (Gtk.Stock.DialogWarning, Gtk.IconSize.Dialog), false, false, 0); outer.PackStart (new Gtk.Label (String.Empty)); string msg; string long_msg; if (tag != null) { msg = String.Format (Catalog.GetString ("No photos matching {0} found"), tag.Name); long_msg = String.Format (Catalog.GetString ("The tag \"{0}\" is not applied to any photos. Try adding\n" + "the tag to some photos or selecting a different tag in the\n" + "F-Spot preference dialog."), tag.Name); } else { msg = Catalog.GetString ("Search returned no results"); long_msg = Catalog.GetString ("The tag F-Spot is looking for does not exist. Try\n" + "selecting a different tag in the F-Spot preference\n" + "dialog."); } Gtk.Label label = new Gtk.Label (msg); hbox.PackStart (label, false, false, 0); Gtk.Label long_label = new Gtk.Label (long_msg); long_label.Markup = String.Format ("<small>{0}</small>", long_msg); vbox.PackStart (long_label, false, false, 0); vbox.PackStart (new Gtk.Label (String.Empty)); window.Add (outer); SetStyle (label); SetStyle (long_label); //SetStyle (image); } window.ShowAll (); }
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; }
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); 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 e) { dest = null; } return dest; }
private void InitializeWidgets() { this.Spacing = 10; this.BorderWidth = 10; UserTreeView = new iFolderTreeView(); ScrolledWindow sw = new ScrolledWindow(); sw.ShadowType = Gtk.ShadowType.EtchedIn; sw.Add(UserTreeView); this.PackStart(sw, true, true, 0); UserTreeStore = new ListStore(typeof(iFolderUser)); UserTreeView.Model = UserTreeStore; CellRendererPixbuf mcrp = new CellRendererPixbuf(); TreeViewColumn UserColumn = new TreeViewColumn(); UserColumn.PackStart(mcrp, false); UserColumn.Spacing = 2; UserColumn.SetCellDataFunc(mcrp, new TreeCellDataFunc(UserCellPixbufDataFunc)); CellRendererText mcrt = new CellRendererText(); UserColumn.PackStart(mcrt, false); UserColumn.SetCellDataFunc(mcrt, new TreeCellDataFunc(UserCellTextDataFunc)); UserColumn.Title = Util.GS("User"); UserTreeView.AppendColumn(UserColumn); UserColumn.Resizable = true; CellRendererText statecr = new CellRendererText(); statecr.Xpad = 5; TreeViewColumn stateColumn = UserTreeView.AppendColumn(Util.GS("Role"), statecr, new TreeCellDataFunc(StateCellTextDataFunc)); stateColumn.Resizable = true; stateColumn.MinWidth = 150; CellRendererText accesscr = new CellRendererText(); accesscr.Xpad = 5; TreeViewColumn accessColumn = UserTreeView.AppendColumn(Util.GS("Rights"), accesscr, new TreeCellDataFunc(AccessCellTextDataFunc)); accessColumn.Resizable = true; UserTreeView.Selection.Mode = SelectionMode.Multiple; UserTreeView.Selection.Changed += new EventHandler(OnUserSelectionChanged); UserTreeView.ButtonPressEvent += new ButtonPressEventHandler( OnUserTreeViewButtonPressed); UserTreeView.RowActivated += new RowActivatedHandler( OnUserTreeViewRowActivated); OwnerUserPixbuf = new Gdk.Pixbuf(Util.ImagesPath("ifolder-user-owner16.png")); CurrentUserPixbuf = new Gdk.Pixbuf(Util.ImagesPath("ifolder-user-current16.png")); NormalUserPixbuf = new Gdk.Pixbuf(OwnerUserPixbuf.Colorspace, true, OwnerUserPixbuf.BitsPerSample, OwnerUserPixbuf.Width, OwnerUserPixbuf.Height); NormalUserPixbuf.Fill(0x00000000); HBox buttonBox = new HBox(); buttonBox.Spacing = 10; this.PackStart(buttonBox, false, false, 0); HBox leftBox = new HBox(); leftBox.Spacing = 10; buttonBox.PackStart(leftBox, false, false, 0); HBox midBox = new HBox(); midBox.Spacing = 10; buttonBox.PackStart(midBox, true, true, 0); HBox rightBox = new HBox(); rightBox.Spacing = 10; buttonBox.PackStart(rightBox, false, false, 0); AddButton = new Button(Gtk.Stock.Add); rightBox.PackStart(AddButton); AddButton.Clicked += new EventHandler(OnAddUser); RemoveButton = new Button(Gtk.Stock.Remove); rightBox.PackStart(RemoveButton); RemoveButton.Clicked += new EventHandler(OnRemoveUser); AccessButton = new Button(Util.GS("R_ights...")); leftBox.PackStart(AccessButton); AccessButton.Clicked += new EventHandler(OnAccessClicked); }
public SlideShow(string name) { Tag tag; if (name != null) { tag = Database.Tags.GetTagByName(name); } else { int id = (int)Preferences.Get(Preferences.SCREENSAVER_TAG); tag = Database.Tags.GetTagById(id); } Photo [] photos; if (tag != null) { photos = Database.Photos.Query(new Tag [] { tag }); } else if ((int)Preferences.Get(Preferences.SCREENSAVER_TAG) == 0) { photos = db.Photos.Query(new Tag [] {}); } else { photos = new Photo [0]; } window = new XScreenSaverSlide(); SetStyle(window); if (photos.Length > 0) { Array.Sort(photos, new Photo.RandomSort()); Gdk.Pixbuf black = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, false, 8, 1, 1); black.Fill(0x00000000); slideview = new SlideView(black, photos); window.Add(slideview); } else { Gtk.HBox outer = new Gtk.HBox(); Gtk.HBox hbox = new Gtk.HBox(); Gtk.VBox vbox = new Gtk.VBox(); outer.PackStart(new Gtk.Label(String.Empty)); outer.PackStart(vbox, false, false, 0); vbox.PackStart(new Gtk.Label(String.Empty)); vbox.PackStart(hbox, false, false, 0); hbox.PackStart(new Gtk.Image(Gtk.Stock.DialogWarning, Gtk.IconSize.Dialog), false, false, 0); outer.PackStart(new Gtk.Label(String.Empty)); string msg; string long_msg; if (tag != null) { msg = String.Format(Catalog.GetString("No photos matching {0} found"), tag.Name); long_msg = String.Format(Catalog.GetString("The tag \"{0}\" is not applied to any photos. Try adding\n" + "the tag to some photos or selecting a different tag in the\n" + "F-Spot preference dialog."), tag.Name); } else { msg = Catalog.GetString("Search returned no results"); long_msg = Catalog.GetString("The tag F-Spot is looking for does not exist. Try\n" + "selecting a different tag in the F-Spot preference\n" + "dialog."); } Gtk.Label label = new Gtk.Label(msg); hbox.PackStart(label, false, false, 0); Gtk.Label long_label = new Gtk.Label(long_msg); long_label.Markup = String.Format("<small>{0}</small>", long_msg); vbox.PackStart(long_label, false, false, 0); vbox.PackStart(new Gtk.Label(String.Empty)); window.Add(outer); SetStyle(label); SetStyle(long_label); //SetStyle (image); } window.ShowAll(); }
//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; }
/// <summary> /// Handles the start of processing of a new node. /// </summary> /// <param name="sender"> /// A <see cref="System.Object"/> /// </param> /// <param name="args"> /// A <see cref="EventArgs"/> /// </param> private void OnControllerTokenChecked(object sender, TokenCheckedArgs args) { Application.Invoke(sender, args, delegate(object resender, EventArgs _args) { TokenCheckedArgs a = _args as TokenCheckedArgs; if (!sequencingFinished) { currentToken = a.CurrentToken; FloatBitmap sequenceImage; if (a.LastSequence != null) { TokenSequence joinSeq = new TokenSequence(a.LastSequence); lastToken = joinSeq.Last; joinSeq.Append(currentToken); Token joinedToken = Token.Join(joinSeq, ""); sequenceImage = joinedToken.Image; } else { sequenceImage = currentToken.Image; lastToken = null; } // We add a border to the orginal image. Gdk.Pixbuf sequencePixbuf = sequenceImage.CreatePixbuf(); Gdk.Pixbuf drawnImage = new Gdk.Pixbuf(sequencePixbuf.Colorspace, false, 8, sequencePixbuf.Width + 10, sequencePixbuf.Height + 10); drawnImage.Fill(0xFFFFFFFF); sequencePixbuf.CopyArea(0, 0, sequencePixbuf.Width, sequencePixbuf.Height, drawnImage, 5, 5); if (lastToken != null) { uint color; if (currentToken.CloseFollows(lastToken)) { color = 0x00FF00; sequencingStepResultLbl.Markup = String.Format("<b>Sí, el símbolo «{0}» se añadirá a la secuencia actual</b>", currentToken.Text); } else { color = 0xFF0000; sequencingStepResultLbl.Markup = String.Format("<b>No, «{0}» no puede ser considerado parte de la secuencia ({1})</b>", currentToken.Text, a.LastSequence.ToString()); } Gdk.Pixbuf markedImage = drawnImage.Copy(); // We paint the image of the color markedImage = markedImage.CompositeColorSimple(markedImage.Width, markedImage.Height, Gdk.InterpType.Nearest, 100, 1, color, color); // We are going to mark the image of the to symbols being considered // with their baselines. int min = int.MaxValue; foreach (Token t in a.LastSequence) { if (t.Top < min) { min = t.Top; } } int offset = Math.Min(min, currentToken.Top); int lastBaseline = lastToken.Baseline - offset; int currentBaseline = currentToken.Baseline - offset; markedImage.CopyArea(0, lastBaseline, markedImage.Width, 5, drawnImage, 0, lastBaseline); markedImage.CopyArea(0, currentBaseline, markedImage.Width, 5, drawnImage, 0, currentBaseline); } baselineImageArea.Image = drawnImage; } if (controller.StepMode == ControllerStepMode.StepByStep) { tokenizingNextButtonsAlign.Sensitive = true; } }); }
public static Gdk.Pixbuf GetIcon (this Counter c) { Gdk.Pixbuf cachedIcon; if (icons.TryGetValue (c, out cachedIcon)) return cachedIcon; Gdk.Color gcolor = c.GetColor (); uint color = (((uint)gcolor.Red >> 8) << 24) | (((uint)gcolor.Green >> 8) << 16) | (((uint)gcolor.Blue >> 8) << 8) | 0xff; cachedIcon = new Gdk.Pixbuf (Gdk.Colorspace.Rgb, true, 8, 16, 16); cachedIcon.Fill (color); icons [c] = cachedIcon; return cachedIcon; }
//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; }
/// <summary> /// Set up the UI inside the Window /// </summary> private void InitializeWidgets() { this.Spacing = 10; this.BorderWidth = 10; // Create the main TreeView and add it to a scrolled // window, then add it to the main vbox widget UserTreeView = new iFolderTreeView(); ScrolledWindow sw = new ScrolledWindow(); sw.ShadowType = Gtk.ShadowType.EtchedIn; sw.Add(UserTreeView); this.PackStart(sw, true, true, 0); // Set up the iFolder TreeView UserTreeStore = new ListStore(typeof(iFolderUser)); UserTreeView.Model = UserTreeStore; CellRendererPixbuf mcrp = new CellRendererPixbuf(); TreeViewColumn UserColumn = new TreeViewColumn(); UserColumn.PackStart(mcrp, false); UserColumn.Spacing = 2; UserColumn.SetCellDataFunc(mcrp, new TreeCellDataFunc(UserCellPixbufDataFunc)); CellRendererText mcrt = new CellRendererText(); UserColumn.PackStart(mcrt, false); UserColumn.SetCellDataFunc(mcrt, new TreeCellDataFunc(UserCellTextDataFunc)); UserColumn.Title = Util.GS("User"); UserTreeView.AppendColumn(UserColumn); UserColumn.Resizable = true; CellRendererText statecr = new CellRendererText(); statecr.Xpad = 5; TreeViewColumn stateColumn = UserTreeView.AppendColumn(Util.GS("Role"), statecr, new TreeCellDataFunc(StateCellTextDataFunc)); stateColumn.Resizable = true; stateColumn.MinWidth = 150; CellRendererText accesscr = new CellRendererText(); accesscr.Xpad = 5; TreeViewColumn accessColumn = UserTreeView.AppendColumn(Util.GS("Rights"), accesscr, new TreeCellDataFunc(AccessCellTextDataFunc)); accessColumn.Resizable = true; UserTreeView.Selection.Mode = SelectionMode.Multiple; UserTreeView.Selection.Changed += new EventHandler(OnUserSelectionChanged); UserTreeView.ButtonPressEvent += new ButtonPressEventHandler( OnUserTreeViewButtonPressed); UserTreeView.RowActivated += new RowActivatedHandler( OnUserTreeViewRowActivated); OwnerUserPixbuf = new Gdk.Pixbuf(Util.ImagesPath("ifolder-user-owner16.png")); CurrentUserPixbuf = new Gdk.Pixbuf(Util.ImagesPath("ifolder-user-current16.png")); // Use an empty pixbuf to represent a normal user NormalUserPixbuf = new Gdk.Pixbuf(OwnerUserPixbuf.Colorspace, true, OwnerUserPixbuf.BitsPerSample, OwnerUserPixbuf.Width, OwnerUserPixbuf.Height); NormalUserPixbuf.Fill(0x00000000); // transparent // Set up buttons for add/remove/accept/decline HBox buttonBox = new HBox(); buttonBox.Spacing = 10; this.PackStart(buttonBox, false, false, 0); HBox leftBox = new HBox(); leftBox.Spacing = 10; buttonBox.PackStart(leftBox, false, false, 0); HBox midBox = new HBox(); midBox.Spacing = 10; buttonBox.PackStart(midBox, true, true, 0); HBox rightBox = new HBox(); rightBox.Spacing = 10; buttonBox.PackStart(rightBox, false, false, 0); AddButton = new Button(Gtk.Stock.Add); rightBox.PackStart(AddButton); AddButton.Clicked += new EventHandler(OnAddUser); RemoveButton = new Button(Gtk.Stock.Remove); rightBox.PackStart(RemoveButton); RemoveButton.Clicked += new EventHandler(OnRemoveUser); AccessButton = new Button(Util.GS("R_ights...")); leftBox.PackStart(AccessButton); AccessButton.Clicked += new EventHandler(OnAccessClicked); }