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


C# Pixbuf.Dispose方法代码示例

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


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

示例1: Import

		public void Import (string fileName, Gtk.Window parent)
		{
			Pixbuf bg;

			// Handle any EXIF orientation flags
			using (var fs = new FileStream (fileName, FileMode.Open, FileAccess.Read))
				bg = new Pixbuf (fs);

			bg = bg.ApplyEmbeddedOrientation ();

			Size imagesize = new Size (bg.Width, bg.Height);

			Document doc = PintaCore.Workspace.CreateAndActivateDocument (fileName, imagesize);
			doc.HasFile = true;
			doc.ImageSize = imagesize;
			doc.Workspace.CanvasSize = imagesize;

			Layer layer = doc.AddNewLayer (Path.GetFileName (fileName));

			using (Cairo.Context g = new Cairo.Context (layer.Surface)) {
				CairoHelper.SetSourcePixbuf (g, bg, 0, 0);
				g.Paint ();
			}

			bg.Dispose ();
		}
开发者ID:msiyer,项目名称:Pinta,代码行数:26,代码来源:GdkPixbufFormat.cs

示例2: Adjust

		public Pixbuf Adjust ()
		{
			Gdk.Pixbuf final = new Gdk.Pixbuf (Gdk.Colorspace.Rgb,
							   false, 8,
							   Input.Width,
							   Input.Height);
			Cms.Profile [] list = GenerateAdjustments ().ToArray ();
			
			if (Input.HasAlpha) {
				Pixbuf alpha = PixbufUtils.Flatten (Input);
				Transform transform = new Transform (list,
								     PixbufUtils.PixbufCmsFormat (alpha),
								     PixbufUtils.PixbufCmsFormat (final),
								     intent, 0x0000);
				PixbufUtils.ColorAdjust (alpha, final, transform);
				PixbufUtils.ReplaceColor (final, Input);
				alpha.Dispose ();
				final.Dispose ();
				final = Input;
			} else {
				Cms.Transform transform = new Cms.Transform (list,
									     PixbufUtils.PixbufCmsFormat (Input),
									     PixbufUtils.PixbufCmsFormat (final),
									     intent, 0x0000);
				
				PixbufUtils.ColorAdjust (Input, final, transform);
			}

			return final;
		}
开发者ID:guadalinex-archive,项目名称:guadalinex-v6,代码行数:30,代码来源:Adjustment.cs

示例3: Adjust

		public void Adjust ()
		{
			bool create_version = photo.DefaultVersionId == Photo.OriginalVersionId;
			using (ImageFile img = ImageFile.Create (photo.DefaultVersionUri)) {
				if (image == null)
					image = img.Load ();
			
				if (image_profile == null)
					image_profile = img.GetProfile ();
			}

			if (image_profile == null)
				image_profile = Cms.Profile.CreateStandardRgb ();

			if (destination_profile == null)
				destination_profile = image_profile;

			Gdk.Pixbuf final = new Gdk.Pixbuf (Gdk.Colorspace.Rgb,
							   false, 8,
							   image.Width, 
							   image.Height);
			
			Cms.Profile adjustment_profile = GenerateProfile ();
			Cms.Profile [] list;
			if (adjustment_profile != null)
				list = new Cms.Profile [] { image_profile, adjustment_profile, destination_profile };
			else
				list = new Cms.Profile [] { image_profile, destination_profile };
			
			if (image.HasAlpha) {
				Pixbuf alpha = PixbufUtils.Flatten (image);
				Transform transform = new Transform (list,
								     PixbufUtils.PixbufCmsFormat (alpha),
								     PixbufUtils.PixbufCmsFormat (final),
								     intent, 0x0000);
				PixbufUtils.ColorAdjust (alpha, final, transform);
				PixbufUtils.ReplaceColor (final, image);
				alpha.Dispose ();
				final.Dispose ();
				final = image;
			} else {
				Cms.Transform transform = new Cms.Transform (list,
									     PixbufUtils.PixbufCmsFormat (image),
									     PixbufUtils.PixbufCmsFormat (final),
									     intent, 0x0000);
				
				PixbufUtils.ColorAdjust (image, final, transform);
				image.Dispose ();
			}
				
			photo.SaveVersion (final, create_version);
			final.Dispose ();
		}
开发者ID:AminBonyadUni,项目名称:facedetect-f-spot,代码行数:53,代码来源:ColorAdjustment.cs

示例4: Client_DownloadDataCompleted

 void Client_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
 {
     try {
         byte[] data = e.Result;
         Pixbuf temp = new Pixbuf(data);
         if (temp.Width == 100 && temp.Height == 100) {
             ReleaseImage();
             this.Artwork = temp.ScaleSimple(150,150,InterpType.Bilinear);
         }
         temp.Dispose();
     } catch (Exception ex) {
         Console.WriteLine(ex.Source);
         Console.WriteLine(ex.StackTrace);
         ReleaseImage();
     }
 }
开发者ID:peter-gregory,项目名称:ClockRadio,代码行数:16,代码来源:FindArtwork.cs

示例5: Import

        public void Import(LayerManager layers, string fileName)
        {
            Pixbuf bg = new Pixbuf (fileName);
            Size imagesize = new Size (bg.Width, bg.Height);

            PintaCore.Workspace.CreateAndActivateDocument (fileName, imagesize);
            PintaCore.Workspace.ActiveDocument.HasFile = true;
            PintaCore.Workspace.ActiveDocument.ImageSize = imagesize;
            PintaCore.Workspace.ActiveWorkspace.CanvasSize = imagesize;

            Layer layer = layers.AddNewLayer (Path.GetFileName (fileName));

            using (Cairo.Context g = new Cairo.Context (layer.Surface)) {
                CairoHelper.SetSourcePixbuf (g, bg, 0, 0);
                g.Paint ();
            }

            bg.Dispose ();
        }
开发者ID:linuxmhall,项目名称:Pinta,代码行数:19,代码来源:GdkPixbufFormat.cs

示例6: AddDirectory

    private static void AddDirectory(Device device, Album album, string dir)
    {
        foreach (string file in Directory.GetFiles (dir)) {
            try {
                Gdk.Pixbuf pixbuf = new Gdk.Pixbuf (file);

                Photo photo = device.PhotoDatabase.CreatePhoto ();

                AddThumbnails (device, photo, pixbuf);
                pixbuf.Dispose ();

                photo.FullSizeFileName = file;
                album.Add (photo);
            } catch (GLib.GException e) {
            } catch (Exception e) {
                Console.WriteLine (e);
            }
        }

        foreach (string child in Directory.GetDirectories (dir)) {
            AddDirectory (device, album, child);
        }
    }
开发者ID:mono,项目名称:ipod-sharp,代码行数:23,代码来源:PhotoAdder.cs

示例7: Run

		public void Run ()
		{
			var poof_file = DockServices.Paths.SystemDataFolder.GetChild ("poof.png");
			if (!poof_file.Exists)
				return;
			
			poof = new Pixbuf (poof_file.Path);
			
			window = new Gtk.Window (Gtk.WindowType.Toplevel);
			window.AppPaintable = true;
			window.Resizable = false;
			window.KeepAbove = true;
			window.CanFocus = false;
			window.TypeHint = WindowTypeHint.Splashscreen;
			window.SetCompositeColormap ();
			
			window.Realized += delegate { window.GdkWindow.SetBackPixmap (null, false); };
			
			window.SetSizeRequest (size, size);
			window.ExposeEvent += HandleExposeEvent;
			
			GLib.Timeout.Add (30, delegate {
				if (AnimationState == 1) {
					window.Hide ();
					window.Destroy ();
					poof.Dispose ();
					return false;
				} else {
					window.QueueDraw ();
					return true;
				}
			});
			
			window.Move (x, y);
			window.ShowAll ();
			run_time = DateTime.UtcNow; 
		}
开发者ID:Aurora-and-Equinox,项目名称:docky,代码行数:37,代码来源:PoofWindow.cs

示例8: CheckImage

		public bool CheckImage (FilePath path)
		{
			Pixbuf pb;
			
			try {
				pb = new Pixbuf (path);
			} catch (Exception e) {
				LoggingService.LogError ("Error loading pixbuf for image chooser,", e);
				MessageService.ShowError (
					GettextCatalog.GetString ("Cannot load image"),
					GettextCatalog.GetString ("The selected file could not be loaded as an image.")
				);
				return false;
			}
			if (AcceptedSize.Width > 0) {
				if (pb.Width != AcceptedSize.Width || pb.Height != AcceptedSize.Height) {
					MessageService.ShowError (GettextCatalog.GetString ("Wrong picture size"),
						GettextCatalog.GetString (
							"Only pictures with size {0}x{1} are accepted. Picture was {2}x{3}.",
							AcceptedSize.Width, AcceptedSize.Height, pb.Width, pb.Height));
					return false;
				}
			}
			pb.Dispose ();
			return true;
		}
开发者ID:hduregger,项目名称:monodevelop,代码行数:26,代码来源:ImageChooser.cs

示例9: OnExposeEvent

		protected override bool OnExposeEvent (EventExpose evnt)
		{
			if (evnt.Window != GdkWindow)
				return true;

			if (extendable && Allocation.Width >= BackgroundPixbuf.Width + (2 * x_offset) + BackgroundTile.Width)
				BackgroundPixbuf = null;

			if (extendable && Allocation.Width < BackgroundPixbuf.Width + (2 * x_offset))
				BackgroundPixbuf = null;

			int xpad = 0, ypad = 0;
			if (Allocation.Width > BackgroundPixbuf.Width + (2 * x_offset))
				xpad = (int) (x_align * (Allocation.Width - (BackgroundPixbuf.Width + (2 * x_offset))));

			if (Allocation.Height > BackgroundPixbuf.Height + (2 * y_offset))
				ypad = (int) (y_align * (Allocation.Height - (BackgroundPixbuf.Height + (2 * y_offset))));

			GdkWindow.DrawPixbuf (Style.BackgroundGC (StateType.Normal), BackgroundPixbuf, 
					0, 0, x_offset + xpad, y_offset + ypad, 
					BackgroundPixbuf.Width, BackgroundPixbuf.Height, Gdk.RgbDither.None, 0, 0);

			//drawing the icons...
			start_indexes = new Hashtable ();

			Pixbuf icon_pixbuf = new Pixbuf (Gdk.Colorspace.Rgb, true, 8, BackgroundPixbuf.Width, thumb_size);
			icon_pixbuf.Fill (0x00000000);

			Pixbuf current = GetPixbuf ((int) Math.Round (Position));
			int ref_x = (int)(icon_pixbuf.Width / 2.0 - current.Width * (Position + 0.5f - Math.Round (Position))); //xpos of the reference icon

			int start_x = ref_x;
			for (int i = (int) Math.Round (Position); i < selection.Collection.Count; i++) {
				current = GetPixbuf (i, ActiveItem == i);
				current.CopyArea (0, 0, Math.Min (current.Width, icon_pixbuf.Width - start_x) , current.Height, icon_pixbuf, start_x, 0);
				start_indexes [start_x] = i; 
				start_x += current.Width + spacing;
				if (start_x > icon_pixbuf.Width)
					break;
			}
			filmstrip_end_pos = start_x;

			start_x = ref_x;
			for (int i = (int) Math.Round (Position) - 1; i >= 0; i--) {
				current = GetPixbuf (i, ActiveItem == i);
				start_x -= (current.Width + spacing);
				current.CopyArea (Math.Max (0, -start_x), 0, Math.Min (current.Width, current.Width + start_x), current.Height, icon_pixbuf, Math.Max (start_x, 0), 0);
				start_indexes [Math.Max (0, start_x)] = i; 
				if (start_x < 0)
					break;
			}
			
			GdkWindow.DrawPixbuf (Style.BackgroundGC (StateType.Normal), icon_pixbuf,
					0, 0, x_offset + xpad, y_offset + ypad + thumb_offset,
					icon_pixbuf.Width, icon_pixbuf.Height, Gdk.RgbDither.None, 0, 0);

			icon_pixbuf.Dispose ();

			return true;
		}
开发者ID:guadalinex-archive,项目名称:guadalinex-v6,代码行数:60,代码来源:Filmstrip.cs

示例10: OnLogodrawingareaExposeEvent

        protected virtual void OnLogodrawingareaExposeEvent(object o, Gtk.ExposeEventArgs args)
        {
            Gdk.Window win;
            Pixbuf frame;
            int width, height, allocWidth, allocHeight, logoX, logoY;
            float ratio;

            if (logopix == null)
                return;

            win = logodrawingarea.GdkWindow;
            width = logopix.Width;
            height = logopix.Height;
            allocWidth = logodrawingarea.Allocation.Width;
            allocHeight = logodrawingarea.Allocation.Height;

            // Checking if allocated space is smaller than our logo
            if ((float) allocWidth / width > (float) allocHeight / height) {
                ratio = (float) allocHeight / height;
            } else {
                ratio = (float) allocWidth / width;
            }
            width = (int) (width * ratio);
            height = (int) (height * ratio);

            logoX = (allocWidth / 2) - (width / 2);
            logoY = (allocHeight / 2) - (height / 2);

            // Drawing our frame
            frame = new Pixbuf(Colorspace.Rgb, false, 8, allocWidth, allocHeight);
            logopix.Composite(frame, 0, 0, allocWidth, allocHeight, logoX, logoY,
                              ratio, ratio, InterpType.Bilinear, 255);

            win.DrawPixbuf (this.Style.BlackGC, frame, 0, 0,
                            0, 0, allocWidth, allocHeight,
                            RgbDither.Normal, 0, 0);
            frame.Dispose();
            return;
        }
开发者ID:dineshkummarc,项目名称:chronojump,代码行数:39,代码来源:CapturerBin.cs

示例11: Animate

	static bool Animate ()
	{
		if (walking) {
			current_frame_num += FRAME_STEP;

			if (current_frame_num > WALK_CYCLE_END) {
				num_walks++;
				if (num_walks > 10) {
					num_walks = 0;
					walking = false;
					current_frame_num = DEATH_CYCLE_START;
				}
				else {
					current_frame_num = WALK_CYCLE_START;
				}
			}
		}
		else /* dying */ {
			if (current_frame_num == DEATH_CYCLE_END) {
				death_timer ++;
				if (death_timer == 30) {
					death_timer = 0;
					walking = true;
					current_frame_num = WALK_CYCLE_START;
				}
			}
			else
				current_frame_num ++;
		}

		byte[] pixbuf_data = CreatePixbufData (grp.GetFrame (current_frame_num),
						       grp.Width, grp.Height,
						       Palette.default_palette);

		Gdk.Pixbuf temp = new Gdk.Pixbuf (pixbuf_data,
						  Colorspace.Rgb,
						  false,
						  8,
						  grp.Width, grp.Height,
						  grp.Width * 3,
						  null);

		current_frame = temp.ScaleSimple (grp.Width * 2, grp.Height * 2, InterpType.Nearest);

		temp.Dispose();

		drawing_area.QueueDraw ();

		return true;
	}
开发者ID:carriercomm,项目名称:scsharp,代码行数:50,代码来源:animate-grp.cs

示例12: GetScaled

		private Pixbuf GetScaled (Pixbuf orig)
		{
			Gdk.Rectangle pos;
			int width = Allocation.Width;
			int height = Allocation.Height;
			double scale = PixbufUtils.Fit (orig, width, height, false, out pos.Width, out pos.Height);
			pos.X = (width - pos.Width) / 2;
			pos.Y = (height - pos.Height) / 2;
			
			Pixbuf scaled = new Pixbuf (Colorspace.Rgb, false, 8, width, height);
			scaled.Fill (0x000000); 
			
			Rectangle rect = new Rectangle (pos.X, pos.Y, 256, 256);
			Rectangle subarea;
			
			while (rect.Top < pos.Bottom) {
				while (rect.X < pos.Right) {
					if (IsRealized) 
						GdkWindow.ProcessUpdates (false);

					rect.Intersect (pos, out subarea);
					orig.Composite (scaled, subarea.X, subarea.Y, 
							subarea.Width, subarea.Height,
							pos.X, pos.Y, scale, scale,
							Gdk.InterpType.Bilinear,
							255);
					rect.X += rect.Width;
				}
				rect.X = pos.X;
				rect.Y += rect.Height;
			}
			
			orig.Dispose ();
			return scaled;
		}
开发者ID:AminBonyadUni,项目名称:facedetect-f-spot,代码行数:35,代码来源:SlideView.cs

示例13: ProcessThumbnail

    // This method is run through a thread.
    private void ProcessThumbnail()
    {
        Gtk.Application.Invoke(delegate{
            progressbar3.Text = "Processing...";
            //progressbar3.PulseStep = 0.3;
            //progressbar3.Pulse();
          });
          Thread.Sleep(700); // wait for 0.7 seconds. This way, if the user gets
          // jumpy and selects a lot of files quickly, the thread would be
          // interrupted before it reaches the processing of file stage, hence
          // saving processing power and RAM consumption.
          string[] filenames = filechooserdialog1.Filenames;
          if (filenames == null || filenames.Length == 0) return;
          string filename = filenames[filenames.Length - 1];

          if (System.IO.Directory.Exists(filename)) {
            _buf = DeskFlickrUI.GetInstance().GetDFOThumbnail();
          }
          else {
          		  try {
          		    // Scalesimple creates a new pixbuf buffer, with the scaled
          		    // version of the image. If we do, _buf = _buf.ScaleSimple, the
          		    // originally loaded buffer remains referenced, and hence,
          		    // causes memory leak. Instead, we use a different buffer to load
          		    // file, and then dispose it once the image is scaled.
          		    Gdk.Pixbuf original = new Gdk.Pixbuf(filename);
              _buf = original.ScaleSimple(150, 150, Gdk.InterpType.Bilinear);
              original.Dispose();
            } catch (GLib.GException) {
              _buf = DeskFlickrUI.GetInstance().GetDFOThumbnail();
            }
          		}
          Gtk.Application.Invoke (delegate {
          		  image6.Pixbuf = _buf;
          		  label16.Markup = GetInfo(filename);
          		  progressbar3.Text = "";
          });
    }
开发者ID:joshuacox,项目名称:dfo,代码行数:39,代码来源:UploadFileChooserUI.cs

示例14: HandleSelectionChanged

		private void HandleSelectionChanged ()
		{
			int x, y, width, height;
			Gdk.Pixbuf tmp = null;
		       
			image_view.GetSelection (out x, out y, out width, out height);
//			if (width > 0 && height > 0) 
//				icon_view.Selection.Clear ();
				
			if (image_view.Pixbuf != null) {
				if (width > 0 && height > 0) {
					tmp = new Gdk.Pixbuf (image_view.Pixbuf, x, y, width, height);
					
					//FIXME
					PreviewPixbuf = PixbufUtils.TagIconFromPixbuf (tmp);
					PreviewPixbuf_WithoutProfile = PreviewPixbuf.Copy();
					FSpot.ColorManagement.ApplyScreenProfile (PreviewPixbuf);
					
					tmp.Dispose ();
				} else {
					//FIXME
					PreviewPixbuf = PixbufUtils.TagIconFromPixbuf (image_view.Pixbuf);
					PreviewPixbuf_WithoutProfile = PreviewPixbuf.Copy();
					FSpot.ColorManagement.ApplyScreenProfile (PreviewPixbuf);
				}
			}
		}
开发者ID:guadalinex-archive,项目名称:guadalinex-v6,代码行数:27,代码来源:TagCommands.cs

示例15: CheckImage

		public bool CheckImage (FilePath path)
		{
			Pixbuf pb;
			
			try {
				pb = new Pixbuf (path);
			} catch (Exception e) {
				LoggingService.LogError ("Error loading pixbuf for image chooser,", e);
				MessageService.ShowError (
					GettextCatalog.GetString ("Cannot load image"),
					GettextCatalog.GetString ("The selected file could not be loaded as an image.")
				);
				return false;
			}
			if (!CheckImageSize (pb))
				return false;
			pb.Dispose ();
			return true;
		}
开发者ID:jfcantin,项目名称:monodevelop,代码行数:19,代码来源:ImageChooser.cs


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