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


C# ThumbnailSize类代码示例

本文整理汇总了C#中ThumbnailSize的典型用法代码示例。如果您正苦于以下问题:C# ThumbnailSize类的具体用法?C# ThumbnailSize怎么用?C# ThumbnailSize使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: CreateThumbnail

		bool CreateThumbnail (SafeUri thumbnailUri, ThumbnailSize size, IImageFile imageFile)
		{
			var pixels = size == ThumbnailSize.Normal ? 128 : 256;
			Pixbuf pixbuf;
			try {
				pixbuf = imageFile.Load ();
			} catch (Exception e) {
				Log.DebugFormat ("Failed loading image for thumbnailing: {0}", imageFile.Uri);
				Log.DebugException (e);
				return false;
			}

			double scale_x = (double)pixbuf.Width / pixels;
			double scale_y = (double)pixbuf.Height / pixels;
			double scale = Math.Max (1.0, Math.Max (scale_x, scale_y));
			// Ensures that the minimum value is 1 so that pixbuf.ScaleSimple doesn't return null
			// Seems to only happen in rare(?) cases
			int target_x = Math.Max ((int)(pixbuf.Width / scale), 1);
			int target_y = Math.Max ((int)(pixbuf.Height / scale), 1);

			var thumb_pixbuf = pixbuf.ScaleSimple (target_x, target_y, InterpType.Bilinear);
			var mtime = fileSystem.File.GetMTime (imageFile.Uri).ToString ();
			thumb_pixbuf.Savev (thumbnailUri.LocalPath, "png",
				new string [] { ThumbnailService.ThumbUriOpt, ThumbnailService.ThumbMTimeOpt, null },
				new string [] { imageFile.Uri, mtime });

			pixbuf.Dispose ();
			thumb_pixbuf.Dispose ();

			return true;
		}
开发者ID:mono,项目名称:f-spot,代码行数:31,代码来源:ImageThumbnailer.cs

示例2: TryCreateThumbnail

		public bool TryCreateThumbnail (SafeUri thumbnailUri, ThumbnailSize size)
		{
			try {
				var imageFile = ImageFile.Create (fileUri);
				return CreateThumbnail (thumbnailUri, size, imageFile);
			}
			catch {
				return false;
			}
		}
开发者ID:mono,项目名称:f-spot,代码行数:10,代码来源:ImageThumbnailer.cs

示例3: GetDeceasedThumbnailKey

 public ThumbnailKey GetDeceasedThumbnailKey(ThumbnailSize size, int thumbIndex)
 {
     if (mSim is MiniSimDescription)
     {
         return GetThumbnailKey(size, thumbIndex);
     }
     else
     {
         return mSim.GetDeceasedThumbnailKey(size, thumbIndex);
     }
 }
开发者ID:Robobeurre,项目名称:NRaas,代码行数:11,代码来源:MiniSimDescriptionProxy.cs

示例4: GetThumbnailImageUrl

 public static string GetThumbnailImageUrl(string id, ThumbnailSize size = ThumbnailSize.Small)
 {
     switch (size)
     {
         case ThumbnailSize.Large:
             return string.Format("//i.ytimg.com/vi/{0}/hqdefault.jpg", id);
         case ThumbnailSize.Medium:
             return string.Format("//i.ytimg.com/vi/{0}/mqdefault.jpg", id);
         default:
             return string.Format("//i.ytimg.com/vi/{0}/default.jpg", id);
     }
 }
开发者ID:jammykam,项目名称:BrainJocks.YouTubeVideoField,代码行数:12,代码来源:YouTubeVideoField.cs

示例5: GetThumbnail

		public Pixbuf GetThumbnail (SafeUri fileUri, ThumbnailSize size)
		{
			var thumbnailUri = GetThumbnailPath (fileUri, size);
			var thumbnail = LoadThumbnail (thumbnailUri);
			if (IsValid (fileUri, thumbnail))
				return thumbnail;
			IThumbnailer thumbnailer = thumbnailerFactory.GetThumbnailerForUri (fileUri);
			if (thumbnailer == null)
				return null;
			return !thumbnailer.TryCreateThumbnail (thumbnailUri, size)
				? null
				: LoadThumbnail (thumbnailUri);
		}
开发者ID:mono,项目名称:f-spot,代码行数:13,代码来源:ThumbnailService.cs

示例6: ThumbnailSizeToURIString

 /// <summary>
 /// Converts a <see cref="ThumbnailSize"/> to string.
 /// </summary>
 /// <param name="sz"></param>
 /// <returns></returns>
 public static string ThumbnailSizeToURIString(ThumbnailSize sz)
 {
     switch (sz)
     {
         case ThumbnailSize.BigSquare: return "b";
         case ThumbnailSize.Huge: return "h";
         case ThumbnailSize.Large: return "l";
         case ThumbnailSize.Medium: return "m";
         case ThumbnailSize.Small: return "t";
         case ThumbnailSize.SmallSquare: return "s";
         default:
             throw new Exception("Invalid ThumbnailSize!");
     }
 }
开发者ID:Ranlaorn,项目名称:Imgur.API,代码行数:19,代码来源:ImgurHelper.cs

示例7: ThumbnailMaxHeight

 public void ThumbnailMaxHeight(ThumbnailSize size)
 {
     File file = null;
     try
     {
         file = PostImageFile("testimage.jpg");
         Image thumbnail = GetThumbnail(file, maxHeight: size);
         Assert.That(thumbnail, Is.Not.Null);
         Assert.That(thumbnail.Height, Is.LessThanOrEqualTo(int.Parse(size.Description())));
     }
     finally
     {
         Client.Delete(file);
     }
 }
开发者ID:reckcn,项目名称:box-csharp-sdk-v2,代码行数:15,代码来源:ThumbnailTests.cs

示例8: ThumbnailHeightBounded

 public void ThumbnailHeightBounded(ThumbnailSize minHeight, ThumbnailSize maxHeight)
 {
     File file = null;
     try
     {
         file = PostImageFile("testimage.jpg");
         Image thumbnail = GetThumbnail(file, minHeight: minHeight, maxHeight: maxHeight);
         Assert.That(thumbnail, Is.Not.Null);
         Assert.That(thumbnail.Height, Is.GreaterThanOrEqualTo(int.Parse(minHeight.Description())));
         Assert.That(thumbnail.Height, Is.LessThanOrEqualTo(int.Parse(maxHeight.Description())));
     }
     finally
     {
         Client.Delete(file);
     }
 }
开发者ID:reckcn,项目名称:box-csharp-sdk-v2,代码行数:16,代码来源:ThumbnailTests.cs

示例9: LoadThumbnail

        public static Pixbuf LoadThumbnail(SafeUri uri, ThumbnailSize size, PixbufLoader loader)
        {
            var thumb_uri = ThumbUri (uri, size);
            var pixbuf = LoadFromUri (thumb_uri);
            if (!IsValid (uri, pixbuf)) {
                Log.DebugFormat ("Invalid thumbnail, reloading: {0}", uri);
                if (pixbuf != null)
                    pixbuf.Dispose ();

                if (loader == null)
                    return null;

                pixbuf = CreateFrom (uri, thumb_uri, size, loader);
            }
            return pixbuf;
        }
开发者ID:modulexcite,项目名称:f-spot,代码行数:16,代码来源:XdgThumbnailSpec.cs

示例10: ThumbnailSizeString

 /// <summary>
 /// Converts the ThumbnailSize enum to the string equivalent for the API
 /// </summary>
 /// <param name="size"></param>
 /// <returns></returns>
 private string ThumbnailSizeString(ThumbnailSize size)
 {
     switch (size)
     {
         case ThumbnailSize.Small:
             return "small";
         case ThumbnailSize.Medium:
             return "medium";
         case ThumbnailSize.Large:
             return "large";
         case ThumbnailSize.ExtraLarge:
             return "l";
         case ThumbnailSize.ExtraLarge2:
             return "xl";
     }
     return "s";
 }
开发者ID:danielkornev,项目名称:DropNetRT,代码行数:22,代码来源:Client.Helpers.cs

示例11: GetThumbnailKey

        public static ThumbnailKey GetThumbnailKey(IMiniSimDescription ths, ThumbnailSize size, int thumbIndex)
        {
            try
            {
                if (ths == null) return ThumbnailKey.kInvalidThumbnailKey;

                MiniSimDescription miniSim = ths as MiniSimDescription;
                if (miniSim != null)
                {
                    if (!ThumbnailManager.KeyExistsInDB(miniSim.mThumbKey))
                    {
                        SimDescription sim = MiniSims.UnpackSim(miniSim);

                        ThumbnailKey thumbnailKey = sim.GetThumbnailKey(ThumbnailSize.Large, 0x0);

                        try
                        {
                            sim.Dispose(false, true);
                        }
                        catch (Exception e)
                        {
                            Common.Exception(sim, e);
                        }

                        return thumbnailKey;
                    }

                    return miniSim.mThumbKey;
                }
                else if ((ths.CASGenealogy == null) || (ths.CASGenealogy.IsAlive()))
                {
                    return ths.GetThumbnailKey(size, thumbIndex);
                }
                else
                {
                    return ths.GetDeceasedThumbnailKey(size, thumbIndex);
                }
            }
            catch (Exception e)
            {
                Common.Exception(ths.FullName, e);
                return ThumbnailKey.kInvalidThumbnailKey;
            }
        }
开发者ID:Robobeurre,项目名称:NRaas,代码行数:44,代码来源:MiniSims.cs

示例12: GetTumbnailFromSummaryInformation

		/// <summary>
		/// Gets a thumbnail image for the virtual machine (Implementation).
		/// </summary>
		/// <param name="vmId">Virtual machine id, represented by Guid (for example "4664215D-D195-4E35-BB6F-BFC1F17666EB").</param>
		/// <param name="size">Size of the thumbnail being requested</param>
		/// <returns>Array of bytes representing the virtual machine thumbnail image requested.</returns>
		private byte[] GetTumbnailFromSummaryInformation(string vmName, ThumbnailSize size)
		{
			int width = 80;
			int height = 60;

			if (size == ThumbnailSize.Medium160x120)
			{
				width = 160;
				height = 120;
			}
			else if (size == ThumbnailSize.Large320x240)
			{
				width = 320;
				height = 240;
			}

			lock (HostinfoByVMName)
			{
				if (!HostinfoByVMName.ContainsKey(vmName))
				{
					using (WSPVirtualMachineManagementServiceClient client = GetVMMSClient())
					{
						VirtualMachineInfo vminfo = client.GetVirtualMachineByName(vmName);
						if (vminfo != null)
						{
							HostInfo host = client.GetHostById(vminfo.HostId);

							HostinfoByVMName.Add(vmName, host);
						}
					}
				}
			}

			HostInfo hostInfo = null;

			HostinfoByVMName.TryGetValue(vmName, out hostInfo);

			byte[] imgData = null;

			if (hostInfo != null)
			{
				using (WSPVirtualMachineManagementServiceClient client = GetVMMSClient())
				{
					try
					{
						imgData = client.GetVirtualSystemThumbnailImage(width, height, vmName, hostInfo.ComputerName);
					}
					catch (Exception ex)
					{
						imgData = null;
						//
						Log.WriteError(ex);
					}
				}
			}

			// Create new bitmap
			if (imgData == null)
			{
				using (Bitmap bmp = new Bitmap(width, height))
				{
					Graphics g = Graphics.FromImage(bmp);
					SolidBrush brush = new SolidBrush(Color.LightGray);
					g.FillRectangle(brush, 0, 0, width, height);

					using (MemoryStream stream = new MemoryStream())
					{
						bmp.Save(stream, ImageFormat.Png);
						imgData = stream.ToArray();
					}
				}
			}

			return imgData;
		}
开发者ID:lwhitelock,项目名称:Websitepanel,代码行数:81,代码来源:HyperVForPC.cs

示例13: GetVirtualMachineThumbnailImage

		/// <summary>
		/// Gets a thumbnail image for the virtual machine (Wrapper).
		/// </summary>
		/// <param name="vmId">Virtual machine id, represented by Guid (for example "4664215D-D195-4E35-BB6F-BFC1F17666EB").</param>
		/// <param name="size">Size of the thumbnail being requested</param>
		/// <returns>Array of bytes representing the virtual machine thumbnail image requested.</returns>
		public byte[] GetVirtualMachineThumbnailImage(string vmId, ThumbnailSize size)
		{
			return GetTumbnailFromSummaryInformation(vmId, size);
		}
开发者ID:lwhitelock,项目名称:Websitepanel,代码行数:10,代码来源:HyperVForPC.cs

示例14: GetSnapshotThumbnailImage

		public byte[] GetSnapshotThumbnailImage(string snapshotId, ThumbnailSize size)
		{
			//            ManagementBaseObject objSummary = GetSnapshotSummaryInformation(snapshotId, (SummaryInformationRequest)size);

			using (WSPVirtualMachineManagementServiceClient client = GetVMMSClient())
			{

				VirtualMachineInfo vminfo = client.GetVirtualMachineByName(snapshotId);
				HostInfo host = client.GetHostById(vminfo.HostId);

				return GetTumbnailFromSummaryInformation(vminfo.Name, size);
			}
		}
开发者ID:lwhitelock,项目名称:Websitepanel,代码行数:13,代码来源:HyperVForPC.cs

示例15: GetFileThumbnailImage

        /// <summary>
        /// This method returns the thumbnails of a specific file by ID
        /// </summary>
        /// <param name="driveId">The ID of the target drive</param>
        /// <param name="fileId">The ID of the target file</param>
        /// <returns>The file thumbnails for the specific file</returns>
        public static Stream GetFileThumbnailImage(String driveId, String fileId, ThumbnailSize size)
        {
            String jsonResponse = MicrosoftGraphHelper.MakeGetRequestForString(
                String.Format("{0}drives/{1}/items/{2}/thumbnails/0/{3}",
                    MicrosoftGraphHelper.MicrosoftGraphV1BaseUri,
                    driveId,
                    fileId,
                    size.ToString().ToLower()));

            var thumbnail = JsonConvert.DeserializeObject<Thumbnail>(jsonResponse);

            var thumbnailImageStream = MicrosoftGraphHelper.MakeGetRequestForStream(
                thumbnail.Url,
                "image/jpeg");

            return (thumbnailImageStream);
        }
开发者ID:coupalm,项目名称:PnP,代码行数:23,代码来源:FilesHelper.cs


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