Exemple #1
0
	public void Thumbnail (ThumbnailerInfo tinfo)
	{
		lock (thumb_stack) {
			if (!thumb_stack.Contains (tinfo)) {
//                Console.WriteLine ("T: Got request for " + tinfo.source);
				thumb_stack.Push (tinfo);
				thumbnail_sema.Up ();
			}
		}
	}
Exemple #2
0
    public void Thumbnail(ThumbnailerInfo tinfo)
    {
        lock (thumb_stack) {
            if (!thumb_stack.Contains(tinfo))
            {
//                Console.WriteLine ("T: Got request for " + tinfo.source);
                thumb_stack.Push(tinfo);
                thumbnail_sema.Up();
            }
        }
    }
Exemple #3
0
    void ThumbnailFinished()
    {
        lock (thumbs_done) {
            while (thumbs_done.Count > 0)
            {
                ThumbnailerInfo tinfo = (ThumbnailerInfo)thumbs_done.Dequeue();
//                Console.WriteLine ("T: Finished for " + tinfo.source);
                if (OnThumbnailFinished != null)
                {
                    OnThumbnailFinished(this, new ThumbnailFinishedEventArgs(tinfo));
                }
            }
        }
    }
Exemple #4
0
		public ThumbnailFinishedEventArgs (ThumbnailerInfo _tinfo) {
			tinfo = _tinfo;
		}
Exemple #5
0
	public void MakeThumbnail (ThumbnailerInfo tinfo)
	{
		// first check and see if there's a thumbnail in the exif
#if USE_EXIF_THUMBS
		try {
			using (ExifData ed = new ExifData (tinfo.source)) {
				byte [] thumbData = ed.Data;
				if (thumbData.Length > 0) {
					Console.WriteLine ("Trying to write " + tinfo.target);
					// exif contains a thumbnail, so spit it out
					FileStream fs = File.Create (tinfo.target, Math.Min (thumbData.Length, 4096));
					fs.Write (thumbData, 0, thumbData.Length);
					fs.Close ();

					tinfo.thumbnail = null;
					tinfo.status = ThumbnailStatus.OK;
					return;
				}
			}
		} catch {
			Console.WriteLine ("** exif died for " + tinfo.target);
		}
#endif

		// if not found, use GdkPixbuf to scale
		try {
			using (Pixbuf image_pixbuf = new Pixbuf (tinfo.source)) {
				int thumb_width;
				int thumb_height;
				if (image_pixbuf.Width > image_pixbuf.Height) {
					thumb_width = 160;
					thumb_height = (int) (160 * ((float) image_pixbuf.Height / (float) image_pixbuf.Width));
				} else {
					thumb_height = 160;
					thumb_width = (int) (160 * ((float) image_pixbuf.Width / (float) image_pixbuf.Height));
				}

				Pixbuf thumb_pixbuf = image_pixbuf.ScaleSimple (thumb_width, thumb_height, InterpType.Tiles);

				// this will need to be fixed when this particular Gdk.Pixbuf function gets
				// better bindings
				try {
					tinfo.thumbnail = thumb_pixbuf;
					if (tinfo.target.EndsWith ("png")) {
						thumb_pixbuf.Savev (tinfo.target, "png", null, null);
					} else {
						thumb_pixbuf.Savev (tinfo.target, "jpeg", null, null);
					}
				} catch (GLib.GException e) {
					tinfo.status = ThumbnailStatus.UnableToCreate;
					return;
				}

				tinfo.status = ThumbnailStatus.OK;
			}
		} catch (GLib.GException e) {
			tinfo.status = ThumbnailStatus.InvalidSource;
			return;
		}
	}
Exemple #6
0
 public ThumbnailFinishedEventArgs(ThumbnailerInfo _tinfo)
 {
     tinfo = _tinfo;
 }
Exemple #7
0
    public void MakeThumbnail(ThumbnailerInfo tinfo)
    {
        // first check and see if there's a thumbnail in the exif
#if USE_EXIF_THUMBS
        try {
            using (ExifData ed = new ExifData(tinfo.source)) {
                byte [] thumbData = ed.Data;
                if (thumbData.Length > 0)
                {
                    Console.WriteLine("Trying to write " + tinfo.target);
                    // exif contains a thumbnail, so spit it out
                    FileStream fs = File.Create(tinfo.target, Math.Min(thumbData.Length, 4096));
                    fs.Write(thumbData, 0, thumbData.Length);
                    fs.Close();

                    tinfo.thumbnail = null;
                    tinfo.status    = ThumbnailStatus.OK;
                    return;
                }
            }
        } catch {
            Console.WriteLine("** exif died for " + tinfo.target);
        }
#endif

        // if not found, use GdkPixbuf to scale
        try {
            using (Pixbuf image_pixbuf = new Pixbuf(tinfo.source)) {
                int thumb_width;
                int thumb_height;
                if (image_pixbuf.Width > image_pixbuf.Height)
                {
                    thumb_width  = 160;
                    thumb_height = (int)(160 * ((float)image_pixbuf.Height / (float)image_pixbuf.Width));
                }
                else
                {
                    thumb_height = 160;
                    thumb_width  = (int)(160 * ((float)image_pixbuf.Width / (float)image_pixbuf.Height));
                }

                Pixbuf thumb_pixbuf = image_pixbuf.ScaleSimple(thumb_width, thumb_height, InterpType.Tiles);

                // this will need to be fixed when this particular Gdk.Pixbuf function gets
                // better bindings
                try {
                    tinfo.thumbnail = thumb_pixbuf;
                    if (tinfo.target.EndsWith("png"))
                    {
                        thumb_pixbuf.Savev(tinfo.target, "png", null, null);
                    }
                    else
                    {
                        thumb_pixbuf.Savev(tinfo.target, "jpeg", null, null);
                    }
                } catch (GLib.GException e) {
                    tinfo.status = ThumbnailStatus.UnableToCreate;
                    return;
                }

                tinfo.status = ThumbnailStatus.OK;
            }
        } catch (GLib.GException e) {
            tinfo.status = ThumbnailStatus.InvalidSource;
            return;
        }
    }