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


C# Pixbuf.ScaleSimple方法代码示例

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


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

示例1: ScaleToMaxSize

	public static Pixbuf ScaleToMaxSize (Pixbuf pixbuf, int width, int height, bool upscale)
	{
		double scale = Math.Min  (width / (double)pixbuf.Width, height / (double)pixbuf.Height);
		int scale_width = (int)(scale * pixbuf.Width);
		int scale_height = (int)(scale * pixbuf.Height);

		Gdk.Pixbuf result;
		if (upscale || (scale < 1.0))
			result = pixbuf.ScaleSimple (scale_width, scale_height, (scale_width > 20) ? Gdk.InterpType.Bilinear : Gdk.InterpType.Nearest);
		else
			result = pixbuf.Copy ();

		CopyThumbnailOptions (pixbuf, result);

		return result;
	}
开发者ID:ArsenShnurkov,项目名称:beagle-1,代码行数:16,代码来源:PixbufUtils.cs

示例2: IconFromPixbuf

	public static Pixbuf IconFromPixbuf (Pixbuf source, int size)
	{
		Pixbuf tmp = null;
		Pixbuf icon = null;

		if (source.Width > source.Height)
			source = tmp = new Pixbuf (source, (source.Width - source.Height) /2, 0, source.Height, source.Height);
		else if (source.Width < source.Height) 
			source = tmp = new Pixbuf (source, 0, (source.Height - source.Width) /2, source.Width, source.Width);

		if (source.Width == source.Height)
			icon = source.ScaleSimple (size, size, InterpType.Bilinear);
		else
			throw new Exception ("Bad logic leads to bad accidents");

		if (tmp != null)
			tmp.Dispose ();
		
		return icon;
	}
开发者ID:ArsenShnurkov,项目名称:beagle-1,代码行数:20,代码来源:PixbufUtils.cs

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