protected virtual void OnOpenbuttonClicked(object sender, System.EventArgs e) { Pixbuf pimage; StreamReader file; FileChooserDialog fChooser = new FileChooserDialog(Catalog.GetString("Choose an image"), (Gtk.Window) this.Toplevel, FileChooserAction.Open, "gtk-cancel", ResponseType.Cancel, "gtk-open", ResponseType.Accept); fChooser.AddFilter(FileFilter); if (fChooser.Run() == (int)ResponseType.Accept) { // For Win32 compatibility we need to open the image file // using a StreamReader. Gdk.Pixbuf(string filePath) uses GLib to open the // input file and doesn't support Win32 files path encoding file = new StreamReader(fChooser.Filename); pimage = new Gdk.Pixbuf(file.BaseStream); if (pimage != null) { var img = new LongoMatch.Common.Image(pimage); img.Scale(THUMBNAIL_MAX_WIDTH, THUMBNAIL_MAX_HEIGHT); player.Photo = img; image.Pixbuf = img.Value; } } fChooser.Destroy(); }
public static MediaFile DiscoverFile(string filePath, bool takeScreenshot = true) { long duration = 0; uint width, height, fps_n, fps_d, par_n, par_d, ret, fps = 0; string container, audio_codec, video_codec; bool has_audio, has_video; float par = 0; IntPtr container_ptr, audio_codec_ptr, video_codec_ptr; IntPtr error = IntPtr.Zero; LongoMatch.Common.Image preview = null; MultimediaFactory factory; IFramesCapturer thumbnailer; ret = lgm_discover_uri(filePath, out duration, out width, out height, out fps_n, out fps_d, out par_n, out par_d, out container_ptr, out video_codec_ptr, out audio_codec_ptr, out error); if (error != IntPtr.Zero) { throw new GLib.GException(error); } if (ret != 0) { throw new Exception(Catalog.GetString("Could not parse file:") + filePath); } has_audio = audio_codec_ptr != IntPtr.Zero; has_video = video_codec_ptr != IntPtr.Zero; container = GLib.Marshaller.PtrToStringGFree(container_ptr); audio_codec = GLib.Marshaller.PtrToStringGFree(audio_codec_ptr); video_codec = GLib.Marshaller.PtrToStringGFree(video_codec_ptr); /* From nanoseconds to milliseconds */ duration = duration / (1000 * 1000); if (has_video) { fps = fps_n / fps_d; par = (float)par_n / par_d; if (takeScreenshot) { factory = new MultimediaFactory(); thumbnailer = factory.GetFramesCapturer(); thumbnailer.Open(filePath); thumbnailer.SeekTime(1000, false); preview = thumbnailer.GetCurrentFrame(THUMBNAIL_MAX_WIDTH, THUMBNAIL_MAX_HEIGHT); thumbnailer.Dispose(); } } return(new LongoMatch.Store.MediaFile(filePath, duration, (ushort)fps, has_audio, has_video, container, video_codec, audio_codec, width, height, par, preview)); }
protected virtual void Update(int actual, int total, LongoMatch.Common.Image frame) { if (actual <= total) { progressbar.Text = Catalog.GetString("Capturing frame: ") + actual + "/" + total; progressbar.Fraction = (double)actual / (double)total; if (frame != null) { if (image.Pixbuf != null) { image.Pixbuf.Dispose(); } image.Pixbuf = frame.Value; } } if (actual == total) { progressbar.Text = Catalog.GetString("Done"); cancelbutton.Visible = false; okbutton.Visible = true; } }
protected virtual void OnOpenbuttonClicked(object sender, System.EventArgs e) { Pixbuf pimage; StreamReader file; FileChooserDialog fChooser = new FileChooserDialog(Catalog.GetString("Choose an image"), (Gtk.Window)this.Toplevel, FileChooserAction.Open, "gtk-cancel",ResponseType.Cancel, "gtk-open",ResponseType.Accept); fChooser.AddFilter(FileFilter); if(fChooser.Run() == (int)ResponseType.Accept) { // For Win32 compatibility we need to open the image file // using a StreamReader. Gdk.Pixbuf(string filePath) uses GLib to open the // input file and doesn't support Win32 files path encoding file = new StreamReader(fChooser.Filename); pimage= new Gdk.Pixbuf(file.BaseStream); if(pimage != null) { var img = new LongoMatch.Common.Image(pimage); img.Scale(THUMBNAIL_MAX_WIDTH, THUMBNAIL_MAX_HEIGHT); player.Photo = img; image.Pixbuf = img.Value; } } fChooser.Destroy(); }