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


C# Gdk.Pixbuf.Dispose方法代码示例

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


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

示例1: ModifyWindowShape

 /// <summary>
 /// this function modifies a window shape
 /// </summary>
 /// <param name="bmp">
 /// the bitmap that has the shape of the window. <see cref="System.Drawing.Bitmap"/>
 /// </param>
 /// <param name="window">
 /// the window to apply the shape change <see cref="Gtk.Window"/>
 /// </param>
 /// <returns>
 /// true if it succeded, either return false <see cref="System.Boolean"/>
 /// </returns>
 public static bool ModifyWindowShape( System.Drawing.Bitmap bmp, Gtk.Window window )
 {
     bool ret = false;
     try
     {
         //save bitmap to stream
         System.IO.MemoryStream stream = new System.IO.MemoryStream();
         bmp.Save( stream, System.Drawing.Imaging.ImageFormat.Png );
         //verry important: put stream on position 0
         stream.Position     = 0;
         //get the pixmap mask
         Gdk.Pixbuf buf      = new Gdk.Pixbuf( stream, bmp.Width, bmp.Height );
         Gdk.Pixmap map1, map2;
         buf.RenderPixmapAndMask( out map1, out map2, 255 );
         //shape combine window
         window.ShapeCombineMask( map2, 0, 0 );
         //dispose
         buf.Dispose();
         map1.Dispose();
         map2.Dispose();
         bmp.Dispose();
         //if evrything is ok return true;
         ret = true;
     }
     catch(Exception ex)
     {
         Console.WriteLine( ex.Message + "\r\n" + ex.StackTrace );
     }
     return ret;
 }
开发者ID:tizianomanni,项目名称:holly-gtk-widgets,代码行数:42,代码来源:WinUtil.cs

示例2: Convert

		public bool Convert (FilterRequest req)
		{
			string source = req.Current.LocalPath;
			System.Uri dest_uri = req.TempUri (System.IO.Path.GetExtension (source));
			string dest = dest_uri.LocalPath;

			using (ImageFile img = ImageFile.Create (source)) {
				bool changed = false;
				
				if (img.Orientation != PixbufOrientation.TopLeft && img is JpegFile) {
					JpegFile jimg = img as JpegFile;
					
					if (img.Orientation == PixbufOrientation.RightTop) {
						JpegUtils.Transform (source,
								     dest,
								     JpegUtils.TransformType.Rotate90);
						changed = true;
					} else if (img.Orientation == PixbufOrientation.LeftBottom) {
						JpegUtils.Transform (source,
								     dest,
								     JpegUtils.TransformType.Rotate270);
						changed = true;
					} else if (img.Orientation == PixbufOrientation.BottomRight) {
						JpegUtils.Transform (source,
								     dest,
								     JpegUtils.TransformType.Rotate180);
						changed = true;
					}
					
					int width, height;
	
					jimg = ImageFile.Create (dest) as JpegFile;
					
					PixbufUtils.GetSize (dest, out width, out height);
	
					jimg.SetOrientation (PixbufOrientation.TopLeft);
					jimg.SetDimensions (width, height);
	
					Gdk.Pixbuf pixbuf = new Gdk.Pixbuf (dest, 160, 120, true);
					jimg.SetThumbnail (pixbuf);
					pixbuf.Dispose ();
	
					jimg.SaveMetaData (dest);
					jimg.Dispose ();
				}
	
				if (changed)
					req.Current = dest_uri;
	
				return changed;
			}
		}
开发者ID:AminBonyadUni,项目名称:facedetect-f-spot,代码行数:52,代码来源:OrientationFilter.cs

示例3: LoadImage

        /// <summary>
        /// Charge une image de test.
        /// </summary>
        private static GreyPixbuf LoadImage(string ImagePath)
        {
            var pixbuf = new Gdk.Pixbuf(ImagePath);

            var scaledPixbuf = pixbuf.ScaleSimple(Config.WindowWidth, Config.WindowHeight,
                                                  Gdk.InterpType.Hyper);
            pixbuf.Dispose();

            return new GreyPixbuf(scaledPixbuf);
        }
开发者ID:RaphaelJ,项目名称:Viola-Jones-Mono,代码行数:13,代码来源:StrongClassifier.cs

示例4: OnDrawPage

		protected override void OnDrawPage (Gtk.PrintContext context, int page_nr)
		{
			base.OnDrawPage (context, page_nr);
			Context cr = context.CairoContext;	

			int ppx, ppy;
			switch (photos_per_page) {
			default:
			case 1: ppx = ppy =1; break;
			case 2: ppx = 1; ppy = 2; break;
			case 4: ppx = ppy = 2; break;
			case 9: ppx = ppy = 3; break;
			}

			//FIXME: if paper is landscape, swap ppx with ppy

			double w = context.Width / ppx;
			double h = context.Height / ppy;

			for (int x = 0; x <= ppx; x++) {
				for (int y = 0; y <= ppy; y++) {
					int p_index = repeat ? page_nr : page_nr * photos_per_page + y * ppx + x;
					if (crop_marks)
						DrawCropMarks (cr, x*w, y*h, w*.1);
					if (x == ppx || y == ppy || p_index >= selected_photos.Length)
						continue;
					using (ImageFile img = new ImageFile (selected_photos[p_index].DefaultVersionUri))
					{
						Gdk.Pixbuf pixbuf;
						try {
							pixbuf = img.Load ();
							FSpot.ColorManagement.ApplyPrinterProfile (pixbuf, img.GetProfile ());
						} catch (Exception e) {
							Log.Exception ("Unable to load image " + selected_photos[p_index].DefaultVersionUri + "\n", e);
							// If the image is not found load error pixbuf
							pixbuf = new Gdk.Pixbuf (PixbufUtils.ErrorPixbuf, 0, 0, 
										      PixbufUtils.ErrorPixbuf.Width, 
										      PixbufUtils.ErrorPixbuf.Height);
						}
						//Gdk.Pixbuf pixbuf = img.Load (100, 100);
						bool rotated = false;
						if (Math.Sign ((double)pixbuf.Width/pixbuf.Height - 1.0) != Math.Sign (w/h - 1.0)) {
							Gdk.Pixbuf d_pixbuf = pixbuf.RotateSimple (Gdk.PixbufRotation.Counterclockwise);
							pixbuf.Dispose ();
							pixbuf = d_pixbuf;
							rotated = true;
						}

						DrawImage (cr, pixbuf, x * w, y * h, w, h);
						DrawComment (context, (x + 1) * w, (rotated ? y : y + 1) * h, (rotated ? w : h) * .025, comment, rotated);
						pixbuf.Dispose ();
					}
				}
			}

		}
开发者ID:guadalinex-archive,项目名称:guadalinex-v6,代码行数:56,代码来源:PrintOperation.cs

示例5: Save

		public void Save ()
		{
			if (!Changed) {
				this.Dialog.Destroy ();
				return;
			}

			if (!view.Item.IsValid)
				return;

			Console.WriteLine ("Saving....");

			Photo photo = (Photo)view.Item.Current;
			try {
				bool create_version = photo.DefaultVersionId == Photo.OriginalVersionId;
				
				Gdk.Pixbuf orig = view.CompletePixbuf ();
				Gdk.Pixbuf final = new Gdk.Pixbuf (Gdk.Colorspace.Rgb,
								   false, 8,
								   orig.Width, 
								   orig.Height);
				
				Cms.Profile abs = AdjustmentProfile ();
				
				// FIXME this shouldn't use the screen as the destination profile.
				Cms.Profile destination = Cms.Profile.GetScreenProfile (view.Screen);
				if (destination == null)
					destination = Cms.Profile.CreateStandardRgb ();
				
				Cms.Profile [] list = new Cms.Profile [] { image_profile, abs, destination };
				Cms.Transform transform = new Cms.Transform (list,
									     PixbufUtils.PixbufCmsFormat (orig),
									     PixbufUtils.PixbufCmsFormat (final),
									     Cms.Intent.Perceptual, 0x0000);
				
				PixbufUtils.ColorAdjust (orig,
							 final,
							 transform);
				
				photo.SaveVersion (final, create_version);
				((PhotoQuery)view.Query).Commit (view.Item.Index);
				final.Dispose ();
			} catch (System.Exception e) {
				string msg = Catalog.GetString ("Error saving adjusted photo");
				string desc = String.Format (Catalog.GetString ("Received exception \"{0}\". Unable to save photo {1}"),
							     e.Message, photo.Name);
				
				HigMessageDialog md = new HigMessageDialog ((Gtk.Window)Dialog.Toplevel,
									    DialogFlags.DestroyWithParent, 
									    Gtk.MessageType.Error, ButtonsType.Ok, 
									    msg,
									    desc);
				md.Run ();
				md.Destroy ();
			}

			this.Dialog.Sensitive = false;
			this.Dialog.Destroy ();
		}
开发者ID:AminBonyadUni,项目名称:facedetect-f-spot,代码行数:59,代码来源:ColorDialog.cs

示例6: GetEmbeddedThumbnail

		public Gdk.Pixbuf GetEmbeddedThumbnail ()
		{
			if (this.ExifData.Data.Length > 0) {
				MemoryStream mem = new MemoryStream (this.ExifData.Data);
				Gdk.Pixbuf thumb = new Gdk.Pixbuf (mem);
				Gdk.Pixbuf rotated = PixbufUtils.TransformOrientation (thumb, this.Orientation);
				
				if (rotated != thumb)
					thumb.Dispose ();
				
				mem.Close ();
				return rotated;
			}
			return null;
		}
开发者ID:guadalinex-archive,项目名称:guadalinex-v6,代码行数:15,代码来源:JpegFile.cs

示例7: GenerateMipMap

        public static void GenerateMipMap (IPhoto photo)
        {
            var mipmap_uri = MipMapUri (photo);
            
            Log.DebugFormat ("Generating mipmap for {0} - {1}", photo.Uri.ToString (), mipmap_uri.AbsoluteUri);
            
            var file = GLib.FileFactory.NewForUri (photo.Uri);
            var pixbuf = new Gdk.Pixbuf (new GLib.GioStream (file.Read (null)));
            
            var imagefile = TagLib.File.Create (new GIOTagLibFileAbstraction () { Uri = photo.Uri }) as TagLib.Image.File;
            var tag = imagefile.ImageTag;
            
            // Correct orientation
            pixbuf = pixbuf.TransformOrientation (tag.Orientation);

            // Determine mode
            var mode = pixbuf.Width > pixbuf.Height ? ScaleMode.Width : ScaleMode.Height;
            var longest = mode == ScaleMode.Width ? pixbuf.Width : pixbuf.Height;

            double scale_factor = Math.Max ((double) longest / 1600, 1.0);

            MipMapFile map = new MipMapFile ();
            List<Gdk.Pixbuf> pixbufs = new List<Gdk.Pixbuf>(7); // Six or seven on average

            if (scale_factor > 1.0) {
                using (var tmp = pixbuf)
                    pixbuf = pixbuf.ScaleSimple ((int) Math.Round (pixbuf.Width / scale_factor), (int) Math.Round (pixbuf.Height / scale_factor), Gdk.InterpType.Bilinear);
            }

            int max;
            do {
                max = Math.Max (pixbuf.Width, pixbuf.Height);
                pixbufs.Add (pixbuf);

                pixbuf = pixbuf.ScaleSimple (pixbuf.Width / 2, pixbuf.Height / 2, Gdk.InterpType.Bilinear);
            } while (max > 64);
            pixbuf.Dispose ();

            // As the mipmap items are built from largest -> smallest, we need to add them in reverse.
            pixbufs.Reverse ();
            foreach (var buf in pixbufs) {
                map.Add (buf);
            }

            map.WriteToUri (mipmap_uri);
        }
开发者ID:rubenv,项目名称:tripod,代码行数:46,代码来源:MipMapGenerator.cs

示例8: IsImage

 public bool IsImage(string fileName)
 {
     try {
         Gdk.Pixbuf pixbuf = new Gdk.Pixbuf(fileName);
         pixbuf.Dispose();
         return(true);
     } catch (GLib.GException) {
         return(false);
     }
 }
开发者ID:BackupTheBerlios,项目名称:nyiv,代码行数:10,代码来源:ImageList.cs

示例9: OnDrawPage

        protected override void OnDrawPage(Gtk.PrintContext context, int page_nr)
        {
            base.OnDrawPage (context, page_nr);
            Context cr = context.CairoContext;

            int ppx, ppy;
            switch (photos_per_page) {
            default:
            case 1: ppx = ppy =1; break;
            case 2: ppx = 1; ppy = 2; break;
            case 4: ppx = ppy = 2; break;
            case 9: ppx = ppy = 3; break;
            case 12: ppx = 3; ppy = 4; break;
            case 20: ppx = 4; ppy = 5; break;
            case 30: ppx = 5; ppy = 6; break;
            }

            //FIXME: if paper is landscape, swap ppx with ppy

            double w = context.Width / ppx;
            double h = context.Height / ppy;

            // compute picture size using 4800DPI
            double mx=(w / 25.4) * 4800, my=(h / 25.4) * 4800;

            for (int x = 0; x <= ppx; x++) {
                for (int y = 0; y <= ppy; y++) {
                    int p_index = repeat ? page_nr : page_nr * photos_per_page + y * ppx + x;
                    if (crop_marks)
                        DrawCropMarks (cr, x*w, y*h, w*.1);
                    if (x == ppx || y == ppy || p_index >= selected_photos.Length)
                        continue;
                    using (var img = ImageFile.Create (selected_photos[p_index].DefaultVersion.Uri))
                    {
                        Gdk.Pixbuf pixbuf;
                        try {
                            pixbuf = img.Load ((int) mx, (int) my);
                            Cms.Profile printer_profile;
                            if (FSpot.ColorManagement.Profiles.TryGetValue (Preferences.Get<string> (Preferences.COLOR_MANAGEMENT_OUTPUT_PROFILE), out printer_profile))
                                FSpot.ColorManagement.ApplyProfile (pixbuf, img.GetProfile (), printer_profile);
                        } catch (Exception e) {
                            Log.Exception ("Unable to load image " + selected_photos[p_index].DefaultVersion.Uri + "\n", e);
                            // If the image is not found load error pixbuf
                            pixbuf = new Gdk.Pixbuf (PixbufUtils.ErrorPixbuf, 0, 0,
                                              PixbufUtils.ErrorPixbuf.Width,
                                              PixbufUtils.ErrorPixbuf.Height);
                        }
                        //Gdk.Pixbuf pixbuf = img.Load (100, 100);
                        bool rotated = false;
                        if (Math.Sign ((double)pixbuf.Width/pixbuf.Height - 1.0) != Math.Sign (w/h - 1.0)) {
                            Gdk.Pixbuf d_pixbuf = pixbuf.RotateSimple (Gdk.PixbufRotation.Counterclockwise);
                            pixbuf.Dispose ();
                            pixbuf = d_pixbuf;
                            rotated = true;
                        }

                        DrawImage (cr, pixbuf, x * w, y * h, w, h);

                        string tag_string = "";
                        foreach (Tag t in selected_photos[p_index].Tags)
                            tag_string = String.Concat (tag_string, t.Name);

                        string label = String.Format (print_label_format,
                                          comment,
                                          selected_photos[p_index].Name,
                                          selected_photos[p_index].Time.ToLocalTime ().ToShortDateString (),
                                          selected_photos[p_index].Time.ToLocalTime ().ToShortTimeString (),
                                          tag_string,
                                          selected_photos[p_index].Description);

                        DrawComment (context, (x + 1) * w, (rotated ? y : y + 1) * h, (rotated ? w : h) * .025, label, rotated);

                        pixbuf.Dispose ();
                    }
                }
            }
        }
开发者ID:GNOME,项目名称:f-spot,代码行数:77,代码来源:PrintOperation.cs

示例10: ForceLoadAttr

        public bool ForceLoadAttr()
        {
            // Don't waste our resources if it has been removed from the list
            if (!removed) {
                if (!IO.File.Exists(filename)) {
                    // mark it as removed so it dosen't get listed as an option, ever
                    removed = true;
                    // set filename to null, so it dosen't get saved on quit
                    filename = null;

                    Console.WriteLine(Catalog.GetString("Cannot find file: {0}"), filename);
                    // No sence doing anything else
                    return false;
                }

                if (mtime == CurrentMtime) {
                    goto done;
                } else	// save mtime
                    mtime = CurrentMtime;

                try {
                    // Not loaded
                    Pixbuf t = new Gdk.Pixbuf(filename);
                    w = t.Width;
                    h = t.Height;
                    t.Dispose();
                // try to catch that random no data exception that will happen dude to inotify catching
                // wallpapers that are created but are not filled with data (yet)
                } catch (GLib.GException) {
                    DrapesApp.WpList.RemoveFromList(filename);
                }

                // Try to generate a thumbnail
                CreateThumnail();
            } else
                return true;

            done:
            // We're done
            init = true;
            return true;
        }
开发者ID:mtanski,项目名称:drapes,代码行数:42,代码来源:Wallpaper.cs

示例11: DrawImage

        private void DrawImage(PageImage pi, Cairo.Context g, Cairo.Rectangle r)
        {
//            Stream strm = null;
//            System.Drawing.Image im = null;
            Gdk.Pixbuf im = null;
            try
            {
//                strm = new MemoryStream (pi.ImageData);
//                im = System.Drawing.Image.FromStream (strm);
                im = new Gdk.Pixbuf(pi.ImageData);
                DrawImageSized(pi, im, g, r);
            }
            finally
            {
//                if (strm != null)
//                    strm.Close();
                if (im != null)
                    im.Dispose();
            }

        }
开发者ID:myersBR,项目名称:My-FyiReporting,代码行数:21,代码来源:RenderCairo.cs

示例12: Finish

		void Finish ()
		{
			// try loading the logo, if this fails, then we use the backup.
			try {
				Gdk.Pixbuf pbuf = new Gdk.Pixbuf (LogoFile);
				pbuf.Dispose ();
				// if we get to this point, the logofile will load just fine
				Icon = LogoFile;
			} catch {
				// delete the bad logofile, if it exists
				if (System.IO.File.Exists (LogoFile))
					System.IO.File.Delete (LogoFile);
				ForcePixbuf = DockServices.Drawing.LoadIcon ("[email protected]" + GetType ().Assembly.FullName, 128, -1);
			}
			
			IsLoaded = true;
			OnFinishedLoading ();
		}
开发者ID:Aurora-and-Equinox,项目名称:docky,代码行数:18,代码来源:Station.cs

示例13: ReadDone

		public void ReadDone (object sender, System.EventArgs args)
		{
			if (result == null)
				return;

			int len = 0;
			try {
				len = stream.EndRead (result);
				//System.Console.WriteLine ("read {0} bytes", len);
				loader.Write (buffer, (ulong)len);
			} catch (System.ObjectDisposedException od) {
				System.Console.WriteLine ("error in endread {0}", od);
				//delay.Start ();
				len = -1;
			} catch (GLib.GException e) {
				System.Console.WriteLine (e.ToString ());
				pixbuf = null;
				len = -1;
			}
			result = null;

			if (len <= 0) {
				if (loader.Pixbuf == null) {
					if (pixbuf != null)
						pixbuf.Dispose ();
					
					pixbuf = null;
				}
				
				UpdateListeners ();
				done_reading = true;
				Close ();
				return;
			}
		}
开发者ID:guadalinex-archive,项目名称:guadalinex-v6,代码行数:35,代码来源:AsyncPixbufLoader.cs

示例14: ToPixbuf

        public static Gdk.Pixbuf ToPixbuf(ArtworkFormat format, byte[] data)
        {
            Gdk.Pixbuf pixbuf = new Gdk.Pixbuf (Gdk.Colorspace.Rgb, false, 8, format.Width, format.Height);
            Gdk.Pixbuf rotated = null;

            switch (format.PixelFormat) {
            case PixelFormat.Rgb565:
                UnpackRgb565 (data, pixbuf, false);
                break;
            case PixelFormat.Rgb565BE:
                UnpackRgb565 (data, pixbuf, true);
                break;
            case PixelFormat.IYUV:
                UnpackIYUV (data, pixbuf);
                break;
            default:
                throw new ApplicationException ("Unknown pixel format: " + format.PixelFormat);
            }

            if (format.Rotation > 0) {
                rotated = Rotate (pixbuf, format.Rotation);
                pixbuf.Dispose ();
                pixbuf = rotated;
            }

            return pixbuf;
        }
开发者ID:mono,项目名称:ipod-sharp,代码行数:27,代码来源:ArtworkHelpers.cs

示例15: OnLogodrawingareaExposeEvent

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

            if(logopix == null)
                return;

            logo = logopix.Value;

            win = logodrawingarea.GdkWindow;
            width = logo.Width;
            height = logo.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 Gdk.Pixbuf(Gdk.Colorspace.Rgb, false, 8, allocWidth, allocHeight);
            logo.Composite(frame, 0, 0, allocWidth, allocHeight, logoX, logoY,
                              ratio, ratio, Gdk.InterpType.Bilinear, 255);

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


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