public ProgressDialog(Window parent) : base() { this.Title = "Updating iPod..."; this.HasSeparator = false; this.TransientFor = parent; this.DefaultWidth = 400; VBox vbox = new VBox(false, 6); vbox.BorderWidth = 6; HBox hbox = new HBox(false, 6); Gdk.PixbufAnimation animation = new Gdk.PixbufAnimation(Assembly.GetExecutingAssembly(), "ipod.gif"); hbox.PackStart(new Gtk.Image(animation), false, false, 0); label = new Label(""); label.Xalign = 0.0f; label.UseMarkup = true; SetEllipsize(label); hbox.PackStart(label, true, true, 0); vbox.PackStart(hbox, true, false, 0); bar = new ProgressBar(); vbox.PackStart(bar, true, false, 0); VBox.PackStart(vbox, false, false, 0); VBox.ShowAll(); notify = new ThreadNotify(new ReadyEvent(OnNotify)); }
void SelectSubImage() { if (subImage < 0 || subImage > this.maxImage) { this.SelectBaseImage(); return; } try { int subImage = this.subImage; this.OpenArchive(); this.subImage = subImage; } catch (Exception ex) { BooruApp.BooruApplication.Log.Log(BooruLog.Category.Image, ex, "Caught exception opening zip for sub image"); this.SelectBaseImage(); return; } try { var entry = this.archive.GetEntry(this.subImage); using (var stream = entry.Open()) { if (this.cachedAnimation != null) { this.cachedAnimation.Dispose(); } this.cachedAnimation = new Gdk.PixbufAnimation(stream); this.SubImageName = entry.Name; } } catch (Exception ex) { BooruApp.BooruApplication.Log.Log(BooruLog.Category.Image, ex, "Caught exception finding zip entry for sub image"); this.cachedAnimation = Resources.LoadResourcePixbufAnimation(Resources.ID_PIXBUFS_NOPREVIEW); } }
public override void Dispose() { System.Diagnostics.Debug.Assert(this.IsDisposed); lock (imageCache) { if (imageCache.ContainsKey(Details.MD5)) { imageCache.Remove(Details.MD5); } //Console.WriteLine ("{0} images left in cache", imageCache.Count); } if (this.cachedAnimation != null) { this.cachedAnimation.Dispose(); } this.cachedAnimation = null; if (this.cachedThumbnail != null) { this.cachedThumbnail.Dispose(); } this.cachedThumbnail = null; if (this.archive != null) { this.archive.Dispose(); } this.archive = null; }
private void CreateThumbnail() { Gdk.PixbufAnimation animation = this.LoadAnimation(); Gdk.Pixbuf staticImage = animation.StaticImage; var dbConfig = BooruApp.BooruApplication.Database.Config; float thumbSize = dbConfig.GetInt("thumbs.size"); float scale = Math.Min(thumbSize / staticImage.Width, thumbSize / staticImage.Height); int w = (int)(staticImage.Width * scale); int h = (int)(staticImage.Height * scale); this.cachedThumbnail = staticImage.ScaleSimple(w, h, Gdk.InterpType.Hyper); if (staticImage.Width > 0 && staticImage.Height > 0) { if (this.Details.Size.IsZero) { BooruApp.BooruApplication.Database.SetImageSize(this.Details.MD5, new Point2D(staticImage.Width, staticImage.Height)); } } // only dispose if not from cached animation if (this.cachedAnimation != animation) { animation.Dispose(); staticImage.Dispose(); } }
/// <summary> /// Loads the pixbuf animation for image, tries loading from file directly, falls back /// on vidthumbs path. /// </summary> /// <returns>The pixbuf animation for image.</returns> /// <param name="path">Path.</param> /// <param name="md5">Md5.</param> public static Gdk.PixbufAnimation LoadPixbufAnimationForImage(string path, string md5) { Gdk.PixbufAnimation animation = null; var configVidthumbsPath = BooruApp.BooruApplication.Database.Config.GetString("vidthumbs.path"); if (!string.IsNullOrEmpty(configVidthumbsPath)) { animation = animation ?? PixbufLoader.LoadPixbufAnimationFromImageFile(configVidthumbsPath + "/" + md5 + ".jpg"); animation = animation ?? PixbufLoader.LoadPixbufAnimationFromImageFile(configVidthumbsPath + "/" + md5 + ".png"); } var configVidthumbsPath2 = BooruApp.BooruApplication.Database.Config.GetString("vidthumbs.path2"); if (!string.IsNullOrEmpty(configVidthumbsPath2)) { animation = animation ?? PixbufLoader.LoadPixbufAnimationFromImageFile(configVidthumbsPath2 + "/" + md5 + ".jpg"); animation = animation ?? PixbufLoader.LoadPixbufAnimationFromImageFile(configVidthumbsPath2 + "/" + md5 + ".png"); } animation = animation ?? PixbufLoader.LoadPixbufAnimationFromImageFile(path); animation = animation ?? new Gdk.PixbufAnimation(null, Resources.ID_PIXBUFS_NOPREVIEW); return(animation); }
public ProgressDialog(Window parent) : base() { this.Title = "Updating iPod..."; this.HasSeparator = false; this.TransientFor = parent; this.DefaultWidth = 400; VBox vbox = new VBox (false, 6); vbox.BorderWidth = 6; HBox hbox = new HBox (false, 6); Gdk.PixbufAnimation animation = new Gdk.PixbufAnimation (Assembly.GetExecutingAssembly (), "ipod.gif"); hbox.PackStart (new Gtk.Image (animation), false, false, 0); label = new Label (""); label.Xalign = 0.0f; label.UseMarkup = true; SetEllipsize (label); hbox.PackStart (label, true, true, 0); vbox.PackStart (hbox, true, false, 0); bar = new ProgressBar (); vbox.PackStart (bar, true, false, 0); VBox.PackStart (vbox, false, false, 0); VBox.ShowAll (); notify = new ThreadNotify (new ReadyEvent (OnNotify)); }
void SelectBaseImage() { this.subImage = -1; if (this.cachedAnimation != null) { this.cachedAnimation.Dispose(); } this.cachedAnimation = null; this.CacheAnimation(); }
void LoadFromStream (System.IO.Stream stream) { try { Gdk.PixbufAnimation anim = new Gdk.PixbufAnimation (stream); if (anim.IsStaticImage) Pixbuf = anim.StaticImage; else PixbufAnimation = anim; } catch { Stock = Gtk.Stock.MissingImage; } }
public StatusLabel() { this.PackStart(image, false, false, 0); this.PackStart(label, true, true, 0); this.PackStart(cancelButton, false, false, 0); this.PackStart(detailsButton, false, false, 0); spinner = Gdk.PixbufAnimation.LoadFromResource("spinner.gif"); this.HeightRequest = spinner.Height; label.Ellipsize = Pango.EllipsizeMode.End; label.Xalign = 0; label.Show(); }
public static Gtk.Image GetAnimation(string filename) { Gdk.PixbufAnimation anipixbuf; if ((anipixbuf = new Gdk.PixbufAnimation(filename)) == null) return(null); if (anipixbuf.IsStaticImage == true) { Gdk.Pixbuf pixbuf; if ((pixbuf = anipixbuf.StaticImage) == null) return(null); return(new Gtk.Image(pixbuf)); } return(new Gtk.Image(anipixbuf)); }
/// <summary> /// Tries loading animation directly from file. /// </summary> /// <returns>The pixbuf animation from image file.</returns> /// <param name="path">Path.</param> private static Gdk.PixbufAnimation LoadPixbufAnimationFromImageFile(string path) { if (!System.IO.File.Exists(path)) { return(null); } try { Gdk.PixbufAnimation animation = new Gdk.PixbufAnimation(path); return(animation); } catch (Exception ex) { BooruApp.BooruApplication.Log.Log(BooruLog.Category.Image, ex, "Caught exception trying to load " + path + " as an image"); return(null); } }
public Image(Gdk.PixbufAnimation animation) : base(IntPtr.Zero) { if (GetType() != typeof(Image)) { var vals = new List <GLib.Value> (); var names = new List <string> (); if (animation != null) { names.Add("pixbuf_animation"); vals.Add(new GLib.Value(animation)); } CreateNativeObject(names.ToArray(), vals.ToArray()); return; } Raw = gtk_image_new_from_animation(animation == null ? IntPtr.Zero : animation.Handle); }
void LoadFromStream(System.IO.Stream stream) { try { Gdk.PixbufAnimation anim = new Gdk.PixbufAnimation(stream); if (anim.IsStaticImage) { Pixbuf = anim.StaticImage; } else { PixbufAnimation = anim; } } catch { Stock = Gtk.Stock.MissingImage; } }
private Gdk.PixbufAnimation CacheAnimation() { if (this.archive == null && this.cachedAnimation == null && this.Details.type == BooruImageType.Comix) { try { this.OpenArchive(); } catch (Exception ex) { BooruApp.BooruApplication.Log.Log(BooruLog.Category.Image, ex, "Caught exception opening zip " + this.Details.Path + " to cache"); } } if (this.cachedAnimation == null) { this.cachedAnimation = this.LoadAnimation(); } return(this.cachedAnimation); }
public MainWindow() : base(Gtk.WindowType.Toplevel) { this.Build(); backButton.Sensitive = false; searchButton.Sensitive = false; previousWidgets = new Stack <EmbeddedWidget> (); errorLabel = new Gtk.Label(); errorLabel.ModifyFont(Pango.FontDescription.FromString("12")); //load the loading animation using (Stream imgStream = GetType().Assembly.GetManifestResourceStream("loadingAnimation")) { loadingAnimation = new Gdk.PixbufAnimation(imgStream); } //load the source images using (Stream imgStream = GetType().Assembly.GetManifestResourceStream("hulu_logo")) { huluLogo = new Gdk.Pixbuf(imgStream); } using (Stream imgStream = GetType().Assembly.GetManifestResourceStream("amazon_logo")) { amazonLogo = new Gdk.Pixbuf(imgStream); } using (Stream imgStream = GetType().Assembly.GetManifestResourceStream("youtube_logo")) { youtubeLogo = new Gdk.Pixbuf(imgStream); } //make a new CancellationSource for a new task loadingResultsCancellationSource = new CancellationTokenSource(); showLoadingScreen(); getPopShows(0); //first embedded widget is popular shows this.ShowAll(); }
public CellRendererCertificate() { anim = new Gdk.PixbufAnimation(ECM.Core.LoadingSpinnerGIF); animIter = anim.GetIter(IntPtr.Zero); }
public ImageLoader() { AnimatedIcon = new Gdk.PixbufAnimation(ECM.Core.LoadingSpinnerGIF); m_Worker.DoWork += new DoWorkEventHandler(RetrieveImage); }
public StatusLabel () { this.PackStart (image, false, false, 0); this.PackStart (label, true, true, 0); this.PackStart (cancelButton, false, false, 0); this.PackStart (detailsButton, false, false, 0); spinner = Gdk.PixbufAnimation.LoadFromResource ("spinner.gif"); this.HeightRequest = spinner.Height; label.Ellipsize = Pango.EllipsizeMode.End; label.Xalign = 0; label.Show (); }
public static BooruImageType IdentifyType(string path, out bool callBooru) { try { byte[] magic = new byte[16]; using (var file = File.OpenRead(path)) { file.Read(magic, 0, 16); } if (magic[0] == 0xff && magic[1] == 0xd8 && magic[2] == 0xff) { // jpeg callBooru = true; return(BooruImageType.Image); } if (magic[0] == 0x89 && magic[1] == 0x50 && magic[2] == 0x4e && magic[3] == 0x47) { // png callBooru = true; return(BooruImageType.Image); } if (magic[0] == 0x47 && magic[1] == 0x49 && magic[2] == 0x46) { // gif callBooru = true; try { Gdk.PixbufAnimation anim = new Gdk.PixbufAnimation(path); var type = anim.IsStaticImage ? BooruImageType.Image : BooruImageType.Animation; anim.Dispose(); return(type); } catch (Exception ex) { BooruApp.BooruApplication.Log.Log(BooruLog.Category.Files, ex, "Caught exception trying to determine image type for " + path); } return(BooruImageType.Image); } if (magic[0] == 0x42 && magic[1] == 0x4d) { // bmp callBooru = true; return(BooruImageType.Image); } if (magic[0] == 0x1a && magic[1] == 0x45 && magic[2] == 0xdf && magic[3] == 0xa3) { // webm/matroshka callBooru = true; return(BooruImageType.Video); } if (magic[0] == 0x30 && magic[1] == 0x26 && magic[2] == 0xb2 && magic[3] == 0x75) { // wmv/wma/asf callBooru = false; return(BooruImageType.Video); } if (magic[8] == 0x41 && magic[9] == 0x56 && magic[10] == 0x49 && magic[11] == 0x20) { // avi callBooru = false; return(BooruImageType.Video); } if (magic[0] == 0x4f && magic[1] == 0x67 && magic[2] == 0x67 && magic[3] == 0x53) { // ogg callBooru = false; return(BooruImageType.Video); } if (magic[0] == 0x46 && magic[1] == 0x4c && magic[2] == 0x56 && magic[3] == 0x01) { // flv callBooru = true; return(BooruImageType.Video); } if (magic[0] == 0x2e && magic[1] == 0x52 && magic[2] == 0x4d && magic[3] == 0x46) { // rmvb callBooru = false; return(BooruImageType.Video); } if (magic[0] == 0x00 && magic[1] == 0x00 && magic[2] == 0x01) { // mpg callBooru = false; return(BooruImageType.Video); } if (magic[4] == 0x66 && magic[5] == 0x74 && magic[6] == 0x79 && magic[7] == 0x70) { // mpeg? callBooru = false; return(BooruImageType.Video); } if (magic[0] == 0x50 && magic[1] == 0x4b && magic[2] == 0x03 && magic[3] == 0x04) { // zip callBooru = false; return(BooruImageType.Comix); } if (magic[0] == 0x52 && magic[1] == 0x61 && magic[2] == 0x72 && magic[3] == 0x21) { // rar callBooru = false; return(BooruImageType.Comix); } if (magic[0] == 0x37 && magic[1] == 0x7A && magic[2] == 0xBC && magic[3] == 0xAF && magic[4] == 0x27 && magic[5] == 0x1C) { // 7z callBooru = false; return(BooruImageType.Comix); } callBooru = false; return(BooruImageType.Unknown); } catch (System.Threading.ThreadAbortException ex) { BooruApp.BooruApplication.Log.Log(BooruLog.Category.Files, ex, "Thread was aborted during image type identification"); } catch (Exception ex) { BooruApp.BooruApplication.Log.Log(BooruLog.Category.Files, ex, "Caught exception determining file type for " + path); } callBooru = false; return(BooruImageType.Unknown); }