当前位置: 首页>>代码示例>>C#>>正文


C# Pixbuf.Dispose方法代码示例

本文整理汇总了C#中Pixbuf.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# Pixbuf.Dispose方法的具体用法?C# Pixbuf.Dispose怎么用?C# Pixbuf.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pixbuf的用法示例。


在下文中一共展示了Pixbuf.Dispose方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Step

	public override bool Step (out Photo photo, out Pixbuf thumbnail, out int count)
	{
		thumbnail = null;

		if (import_info == null)
			throw new ImportException ("Prepare() was not called");

		if (this.count == import_info.Count)
			throw new ImportException ("Already finished");

		// FIXME Need to get the EXIF info etc.
		ImportInfo info = (ImportInfo)import_info [this.count];
		bool needs_commit = false;
		bool abort = false;
		try {
			string destination = info.OriginalPath;
			if (copy)
				destination = ChooseLocation (info.OriginalPath, directories);
			
			// Don't copy if we are already home
			if (info.OriginalPath == destination) {
				info.DestinationPath = destination;
				photo = store.Create (info.DestinationPath, roll.Id, out thumbnail);
			} else {
				System.IO.File.Copy (info.OriginalPath, destination);
				info.DestinationPath = destination;

				photo = store.Create (info.DestinationPath, info.OriginalPath, roll.Id, out thumbnail);

				try {
					File.SetAttributes (destination, File.GetAttributes (info.DestinationPath) & ~FileAttributes.ReadOnly);
					DateTime create = File.GetCreationTime (info.OriginalPath);
					File.SetCreationTime (info.DestinationPath, create);
					DateTime mod = File.GetLastWriteTime (info.OriginalPath);
					File.SetLastWriteTime (info.DestinationPath, mod);
				} catch (IOException) {
					// we don't want an exception here to be fatal.
				}
			} 

			if (tags != null) {
				foreach (Tag t in tags) {
					photo.AddTag (t);
				}
				needs_commit = true;
			}

			needs_commit |= xmptags.Import (photo, info.DestinationPath, info.OriginalPath);

			if (needs_commit)
				store.Commit(photo);
			
			info.Photo = photo;
		} catch (System.Exception e) {
			System.Console.WriteLine ("Error importing {0}{2}{1}", info.OriginalPath, e.ToString (), Environment.NewLine);
			if (thumbnail != null)
				thumbnail.Dispose ();

			thumbnail = null;
			photo = null;

			HigMessageDialog errordialog = new HigMessageDialog (parent,
									     Gtk.DialogFlags.Modal | Gtk.DialogFlags.DestroyWithParent,
									     Gtk.MessageType.Error,
									     Gtk.ButtonsType.Cancel,
									     Catalog.GetString ("Import error"),
									     String.Format(Catalog.GetString ("Error importing {0}{2}{2}{1}"), info.OriginalPath, e.Message, Environment.NewLine ));
			errordialog.AddButton ("Skip", Gtk.ResponseType.Reject, false);
			ResponseType response = (ResponseType) errordialog.Run ();
			errordialog.Destroy ();
			if (response == ResponseType.Cancel)
				abort = true;
		}

		this.count ++;
		count = this.count;

		return (!abort && count != import_info.Count);
	}
开发者ID:AminBonyadUni,项目名称:facedetect-f-spot,代码行数:79,代码来源:FileImportBackend.cs

示例2: HandleIconViewDragBegin

	//
	// IconView Drag Handlers
	//

	void HandleIconViewDragBegin (object sender, DragBeginArgs args)
	{
		Photo [] photos = SelectedPhotos ();
		
		if (photos.Length > 0) {
			int len = Math.Min (photos.Length, 4);
			int size = 48;
			int border  = 2;
			int csize = size/2 + len * size / 2 + 2 * border ;
			
			Pixbuf container = new Pixbuf (Gdk.Colorspace.Rgb, true, 8, csize, csize);
			container.Fill (0x00000000);

			bool use_icon = false;;
			while (len-- > 0) {
				string thumbnail_path = FSpot.ThumbnailGenerator.ThumbnailPath (photos [len].DefaultVersionUri);
				FSpot.PixbufCache.CacheEntry entry = icon_view.Cache.Lookup (thumbnail_path);

				Pixbuf thumbnail = null;
				if (entry != null) {
					if (FSpot.ColorManagement.IsEnabled) {
						//FIXME
						thumbnail = entry.ShallowCopyPixbuf ();
						thumbnail = thumbnail.Copy ();
						FSpot.ColorManagement.ApplyScreenProfile (thumbnail);
					}
					else
						thumbnail = entry.ShallowCopyPixbuf ();
				}
				
				if (thumbnail != null) {
					Pixbuf small = PixbufUtils.ScaleToMaxSize (thumbnail, size, size);				

					int x = border + len * (size/2) + (size - small.Width)/2;
					int y = border + len * (size/2) + (size - small.Height)/2;
					Pixbuf box = new Pixbuf (container, x - border, y - border, 
								 small.Width + 2 * border, small.Height + 2 * border);

					box.Fill (0x000000ff);
					small.CopyArea (0, 0, small.Width, small.Height, container, x, y); 
					
					thumbnail.Dispose ();
					small.Dispose ();
					use_icon = true;
				}
			}
			if (use_icon)
				Gtk.Drag.SetIconPixbuf (args.Context, container, 0, 0);
			container.Dispose ();
		}
	}
开发者ID:guadalinex-archive,项目名称:guadalinex-v6,代码行数:55,代码来源:MainWindow.cs

示例3: HandleTagSelectionDragBegin

	void HandleTagSelectionDragBegin (object sender, DragBeginArgs args)
	{
		Tag [] tags = tag_selection_widget.TagHighlight;
		int len = tags.Length;
		int size = 32;
		int csize = size/2 + len * size / 2 + 2;
		
		Pixbuf container = new Pixbuf (Gdk.Colorspace.Rgb, true, 8, csize, csize);
		container.Fill (0x00000000);
		
		bool use_icon = false;;
		while (len-- > 0) {
			Pixbuf thumbnail = tags[len].Icon;
			
			if (thumbnail != null) {
				Pixbuf small = PixbufUtils.ScaleToMaxSize (thumbnail, size, size);				
				
				int x = len * (size/2) + (size - small.Width)/2;
				int y = len * (size/2) + (size - small.Height)/2;

				small.Composite (container, x, y, small.Width, small.Height, x, y, 1.0, 1.0, Gdk.InterpType.Nearest, 0xff);
				small.Dispose ();

				use_icon = true;
			}
		}
		if (use_icon)
			Gtk.Drag.SetIconPixbuf (args.Context, container, 0, 0);
		container.Dispose ();
	}
开发者ID:guadalinex-archive,项目名称:guadalinex-v6,代码行数:30,代码来源:MainWindow.cs

示例4: Thumbnail

        // Grab thumbnail
        public Pixbuf Thumbnail()
        {
            string		existing;

            // Totaly ignore removed wps
            if (removed)
                return null;

            // Cached thumb nail? Just make sure it's current
            if (ThumbCache != null && HasCurrentThumbnail() == true)
                return ThumbCache;
            else
                ThumbCache = null;

            // Attempt to create a new thumbnail (or at least check if there is an old valid one)
            if (CreateThumnail() == false)
                return null;

            ThumbnailFactory t = new ThumbnailFactory(ThumbnailSize.Normal);

            // Grab the thumb
            existing = t.Lookup(filename, CurrentMtime);
            Pixbuf thumb = new Pixbuf(existing);

            // Figure out the scale for previews
            int x, y;
            switch (Res.ResolutionList.AspectType(w,h)) {
            case Res.Aspect.ASPECT_43:
                x = 64;
                y = 48;
                break;
            case Res.Aspect.ASPECT_WIDE:
                x = 64;
                y = 36;
                break;
            case Res.Aspect.ASPECT_OTHER:
            default:
                x = 64;
                y = 64;
                break;
            }

            // for really small images, do our own resizing; hopefully there won't be too many
            if (thumb.Width < x || thumb.Height < y) {
                ThumbCache = thumb.ScaleSimple(x, y, Gdk.InterpType.Bilinear);
            } else {
                ThumbCache = Gnome.Thumbnail.ScaleDownPixbuf(thumb, x, y);
            }

            thumb.Dispose();
            return ThumbCache;
        }
开发者ID:mtanski,项目名称:drapes,代码行数:53,代码来源:Wallpaper.cs


注:本文中的Pixbuf.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。