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


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

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


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

示例1: CreateFile

		public static string CreateFile (string name, int size)
		{
			using (Gdk.Pixbuf test = new Gdk.Pixbuf (null, "f-spot-32.png")) {
				using (Gdk.Pixbuf tmp = test.ScaleSimple (size, size, Gdk.InterpType.Bilinear)) {
					string path = System.IO.Path.GetTempPath ();
					path = System.IO.Path.Combine (path, name);
					Console.WriteLine (path);
					string extension = System.IO.Path.GetExtension (path);
					string type = "null";
					switch (extension.ToLower ()) {
					case ".jpg":
					case ".jpeg":
						type = "jpeg";
						break;
					case ".png":
						type = "png";
						break;
					case ".tiff":
						type = "tiff";
						break;
					}
					tmp.Save (path, type);
					return path;
				}
			}
		}
开发者ID:AminBonyadUni,项目名称:facedetect-f-spot,代码行数:26,代码来源:ImageTest.cs

示例2: GetIcon

		private Gdk.Pixbuf GetIcon (int size)
		{
			if (Hit.GetFirstProperty ("beagle:Photo") != null) {
				Gdk.Pixbuf icon = new Gdk.Pixbuf (Hit.GetFirstProperty ("beagle:Photo"));
				return icon.ScaleSimple (size, size, Gdk.InterpType.Bilinear);
			} else
				return WidgetFu.LoadThemeIcon ("stock_person", size);
		}
开发者ID:ArsenShnurkov,项目名称:beagle-1,代码行数:8,代码来源:Contact.cs

示例3: CustomBuild

        private void CustomBuild()
        {
            this.PasswordEntry.Visibility = false;
            Gdk.Pixbuf pix = new Gdk.Pixbuf(null, "login_header.png");
            pix = pix.ScaleSimple(this.Allocation.Width, this.TopImage.Allocation.Height, Gdk.InterpType.Bilinear);
            this.TopImage.Pixbuf = pix;

            this.Title = (string) SessionRegistry.GetInstance()["app_name"];
        }
开发者ID:omarkhd,项目名称:gymk,代码行数:9,代码来源:LoginDialog.cs

示例4: CreateFile

 public string CreateFile(string name, int size)
 {
     using (Gdk.Pixbuf test = new Gdk.Pixbuf (null, "f-spot-32.png")) {
         using (Gdk.Pixbuf tmp = test.ScaleSimple (size, size, Gdk.InterpType.Nearest)) {
             string path = System.IO.Path.GetTempPath ();
             path = System.IO.Path.Combine (path, name);
             tmp.Save (path, Path.GetExtension (path).TrimStart (new char [] { '.' }));
             return path;
         }
     }
 }
开发者ID:iainlane,项目名称:f-spot,代码行数:11,代码来源:ThumbnailGenerator.cs

示例5: GetIcon

        public static Gdk.Pixbuf GetIcon(string iconName, int size)
        {
            try {
                return Gtk.IconTheme.Default.LoadIcon (iconName, size, 0);
            } catch (GLib.GException) {}

            try {
                Gdk.Pixbuf ret = new Gdk.Pixbuf (null, iconName + ".png");
                return ret.ScaleSimple (size, size, Gdk.InterpType.Bilinear);
            } catch (ArgumentException) {}

            Logger.Debug ("Unable to load icon '{0}'.", iconName);
            return null;
        }
开发者ID:GNOME,项目名称:banter,代码行数:14,代码来源:Utilities.cs

示例6: OnUpdatePreview

        protected override void OnUpdatePreview()
        {
            try {
                if (String.IsNullOrEmpty (PreviewFilename)) {
                    throw new ApplicationException ();
                }

                using (var pixbuf = new Gdk.Pixbuf (PreviewFilename)) {
                    preview.Pixbuf = pixbuf.ScaleSimple (100, 100, Gdk.InterpType.Bilinear);
                }
                preview.Show ();
            } catch {
                preview.Hide ();
            }
        }
开发者ID:haugjan,项目名称:banshee-hacks,代码行数:15,代码来源:ImageFileChooserDialog.cs

示例7: RadioSourceContents

        public RadioSourceContents()
        {
            HscrollbarPolicy = PolicyType.Never;
            VscrollbarPolicy = PolicyType.Automatic;

            viewport = new Viewport ();
            viewport.ShadowType = ShadowType.None;

            main_box = new VBox ();
            main_box.Spacing = 6;
            main_box.BorderWidth = 5;
            main_box.ReallocateRedraws = true;

            // Clamp the width, preventing horizontal scrolling
            SizeAllocated += delegate(object o, SizeAllocatedArgs args) {
                main_box.WidthRequest = args.Allocation.Width - 10;
            };

            viewport.Add (main_box);

            StyleSet += delegate {
                viewport.ModifyBg (StateType.Normal, Style.Base (StateType.Normal));
                viewport.ModifyFg (StateType.Normal, Style.Text (StateType.Normal));
            };

            logo_pix = new Gdk.Pixbuf (System.Reflection.Assembly.GetExecutingAssembly ()
                                       .GetManifestResourceStream ("logo_color_large.gif"));
            logo = new Image (logo_pix);

            // auto-scale logo
            SizeAllocated += delegate(object o, SizeAllocatedArgs args) {
                int width = args.Allocation.Width - 50;
                logo.Pixbuf = logo_pix.ScaleSimple (width, (int)((float)width / 6.3f), Gdk.InterpType.Bilinear);
            };

            main_box.PackStart (logo, false, false, 0);

            genres = new TitledList ("Genres");
            main_box.PackStart (genres, false, false, 0);

            AddWithFrame (viewport);
            ShowAll ();
        }
开发者ID:nailyk,项目名称:banshee-community-extensions,代码行数:43,代码来源:RadioSourceContents.cs

示例8: 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

示例9: OnGetPixbufForFile

		protected override Gdk.Pixbuf OnGetPixbufForFile (string filename, Gtk.IconSize size)
		{
			//this only works on MacOS 10.6.0 and greater
			if (systemVersion < 0x1060)
				return base.OnGetPixbufForFile (filename, size);
			
			NSImage icon = null;
			
			if (Path.IsPathRooted (filename) && File.Exists (filename)) {
				icon = NSWorkspace.SharedWorkspace.IconForFile (filename);
			} else {
				string extension = Path.GetExtension (filename);
				if (!string.IsNullOrEmpty (extension))
					icon = NSWorkspace.SharedWorkspace.IconForFileType (extension);
			}
			
			if (icon == null) {
				return base.OnGetPixbufForFile (filename, size);
			}
			
			int w, h;
			if (!Gtk.Icon.SizeLookup (Gtk.IconSize.Menu, out w, out h)) {
				w = h = 22;
			}
			var rect = new System.Drawing.RectangleF (0, 0, w, h);
			
			var arep = icon.BestRepresentation (rect, null, null);
			if (arep == null) {
				return base.OnGetPixbufForFile (filename, size);
			}
			
			var rep = arep as NSBitmapImageRep;
			if (rep == null) {
				using (var cgi = arep.AsCGImage (rect, null, null))
					rep = new NSBitmapImageRep (cgi);
				arep.Dispose ();
			}
			
			try {
				byte[] arr;
				using (var tiff = rep.TiffRepresentation) {
					arr = new byte[tiff.Length];
					System.Runtime.InteropServices.Marshal.Copy (tiff.Bytes, arr, 0, arr.Length);
				}
				int pw = rep.PixelsWide, ph = rep.PixelsHigh;
				var px = new Gdk.Pixbuf (arr, pw, ph);
				
				//if one dimension matches, and the other is same or smaller, use as-is
				if ((pw == w && ph <= h) || (ph == h && pw <= w))
					return px;
				
				//else scale proportionally such that the largest dimension matches the desired size
				if (pw == ph) {
					pw = w;
					ph = h;
				} else if (pw > ph) {
					ph = (int) (w * ((float) ph / pw));
					pw = w;
				} else {
					pw = (int) (h * ((float) pw / ph));
					ph = h;
				}
				
				var scaled = px.ScaleSimple (pw, ph, Gdk.InterpType.Bilinear);
				px.Dispose ();
				return scaled;
			} finally {
				if (rep != null)
					rep.Dispose ();
			}
		}
开发者ID:nieve,项目名称:monodevelop,代码行数:71,代码来源:MacPlatform.cs

示例10: CreateWidgets

 private Widget CreateWidgets()
 {
     VBox vbox = new VBox(false, 0);
        AddAccountPixbuf = new Gdk.Pixbuf(Util.ImagesPath("add-account.png"));
        AddAccountPixbuf = AddAccountPixbuf.ScaleSimple(48, 48, Gdk.InterpType.Bilinear);
        AccountDruid = new Gnome.Druid();
        vbox.PackStart(AccountDruid, true, true, 0);
        AccountDruid.ShowHelp = true;
        AccountDruid.Help += new EventHandler(OnAccountWizardHelp);
        AccountDruid.AppendPage(CreateIntroductoryPage());
        AccountDruid.AppendPage(CreateServerInformationPage());
        AccountDruid.AppendPage(CreateUserInformationPage());
        AccountDruid.AppendPage(CreateConnectPage());
        AccountDruid.AppendPage(CreateSummaryPage());
        return vbox;
 }
开发者ID:RoDaniel,项目名称:featurehouse,代码行数:16,代码来源:AddAccountWizard.cs

示例11: Update

 public void Update()
 {
     Dispose();
     if(spectator.Image == null)
     {
         image = ResourceManager.GetPixbuf("Resources", "DefaultPlayerImage.png");
         if(image != null)
             image = image.ScaleSimple(16, 16, Gdk.InterpType.Bilinear);
     }
     else
         image = PictureManager.GetPixbuf(spectator.Image, 16);
     OnChanged();
 }
开发者ID:sciaopin,项目名称:bang-sharp,代码行数:13,代码来源:SessionInfoWidget.cs

示例12: CreateWidgets

 private Widget CreateWidgets()
 {
     EventBox widgetEventbox = new EventBox();
       widgetEventbox.ModifyBg(StateType.Normal, this.Style.Background(StateType.Normal));
        VBox vbox = new VBox(false, 0);
        widgetEventbox.Add(vbox);
        AddAccountPixbuf = new Gdk.Pixbuf(Util.ImagesPath("ifolder-add-account48.png"));
        AddAccountPixbuf = AddAccountPixbuf.ScaleSimple(48, 48, Gdk.InterpType.Bilinear);
        AccountDruid = new Gnome.Druid();
        vbox.PackStart(AccountDruid, true, true, 0);
        AccountDruid.ShowHelp = true;
        AccountDruid.Help += new EventHandler(OnAccountWizardHelp);
        AccountDruid.AppendPage(CreateIntroductoryPage());
        AccountDruid.AppendPage(CreateServerInformationPage());
        AccountDruid.AppendPage(CreateUserInformationPage());
        AccountDruid.AppendPage(CreateConnectPage());
        AccountDruid.AppendPage(CreateRAPage());
        AccountDruid.AppendPage(CreateDefaultiFolderPage());
        AccountDruid.AppendPage(CreateSummaryPage());
        AccountDruid.SetButtonsSensitive(false, true, true, true);
        return widgetEventbox;
 }
开发者ID:RoDaniel,项目名称:featurehouse,代码行数:22,代码来源:AddAccountWizard.cs

示例13: GetMiniIcon

		public static Gdk.Pixbuf GetMiniIcon (string resource_name) 
		{
			Gdk.Pixbuf noicon = new Gdk.Pixbuf (null, resource_name);
			return noicon.ScaleSimple (24, 24, Gdk.InterpType.Nearest);
		}
开发者ID:ArsenShnurkov,项目名称:beagle-1,代码行数:5,代码来源:GtkUtils.cs

示例14: OnGetPixbufForFile

		protected override Gdk.Pixbuf OnGetPixbufForFile (string filename, Gtk.IconSize size)
		{
			NSImage icon = null;
			
			//FIXME: better handling of names of files that haven't been saved yet
			if (Path.IsPathRooted (filename)) {
				icon = NSWorkspace.SharedWorkspace.IconForFile (filename);
			} else {
				icon = NSWorkspace.SharedWorkspace.IconForFile ("/tmp/" + filename);
			}
			
			if (icon != null) {
				int w, h;
				if (!Gtk.Icon.SizeLookup (Gtk.IconSize.Menu, out w, out h))
					w = h = 22;
				var rect = new System.Drawing.RectangleF (0, 0, w, h);
				var rep = icon.BestRepresentation (rect, null, null) as NSBitmapImageRep;
				if (rep != null) {
					var tiff = rep.TiffRepresentation;
					byte[] arr = new byte[tiff.Length];
					System.Runtime.InteropServices.Marshal.Copy (tiff.Bytes, arr, 0, arr.Length);
					int pw = rep.PixelsWide, ph = rep.PixelsHigh;
					var px = new Gdk.Pixbuf (arr, pw, ph);
					
					//if one dimension matches, and the other is same or smaller, use as-is
					if ((pw == w && ph <= h) || (ph == h && pw <= w))
						return px;
					
					//else scale proportionally such that the largest dimension matches the desired size
					if (pw == ph) {
						pw = w;
						ph = h;
					} else if (pw > ph) {
						ph = (int) (w * ((float) ph / pw));
						pw = w;
					} else {
						pw = (int) (h * ((float) pw / ph));
						ph = h;
					}
					
					var scaled = px.ScaleSimple (pw, ph, Gdk.InterpType.Bilinear);
					px.Dispose ();
					return scaled;
				}
			}
			return base.OnGetPixbufForFile (filename, size);
		}
开发者ID:kirill85,项目名称:monodevelop,代码行数:47,代码来源:MacPlatform.cs

示例15: GetPixbufFromNSImageRep

		public static Gdk.Pixbuf GetPixbufFromNSImageRep (NSImageRep rep, int width, int height)
		{
			var rect = new RectangleF (0, 0, width, height);
			var bitmap = rep as NSBitmapImageRep;
			
			if (bitmap == null) {
				using (var cgi = rep.AsCGImage (ref rect, null, null))
					bitmap = new NSBitmapImageRep (cgi);
			}
			
			try {
				byte[] data;
				using (var tiff = bitmap.TiffRepresentation) {
					data = new byte[tiff.Length];
					System.Runtime.InteropServices.Marshal.Copy (tiff.Bytes, data, 0, data.Length);
				}
				
				int pw = bitmap.PixelsWide, ph = bitmap.PixelsHigh;
				var pixbuf = new Gdk.Pixbuf (data, pw, ph);
				
				// if one dimension matches, and the other is same or smaller, use as-is
				if ((pw == width && ph <= height) || (ph == height && pw <= width))
					return pixbuf;
				
				// otherwise scale proportionally such that the largest dimension matches the desired size
				if (pw == ph) {
					pw = width;
					ph = height;
				} else if (pw > ph) {
					ph = (int) (width * ((float) ph / pw));
					pw = width;
				} else {
					pw = (int) (height * ((float) pw / ph));
					ph = height;
				}
				
				var scaled = pixbuf.ScaleSimple (pw, ph, Gdk.InterpType.Bilinear);
				pixbuf.Dispose ();
				
				return scaled;
			} finally {
				if (bitmap != rep)
					bitmap.Dispose ();
			}
		}
开发者ID:pjt33,项目名称:monodevelop,代码行数:45,代码来源:MacPlatform.cs


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