• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ImageSize类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: GetRelativeUrl

		private string GetRelativeUrl(IEntryImageInformation picture, ImageSize size) {
			if (picture.Version > 0) {
				return string.Format("/img/{0}/main{1}/{2}{3}?v={4}", picture.EntryType.ToString().ToLowerInvariant(), GetDir(size), picture.Id, 
					ImageHelper.GetExtensionFromMime(picture.Mime), picture.Version);
			} else
				return string.Format("/img/{0}/main{1}/{2}{3}", picture.EntryType.ToString().ToLowerInvariant(), GetDir(size), picture.Id, ImageHelper.GetExtensionFromMime(picture.Mime));
		}
开发者ID:realzhaorong,项目名称:vocadb,代码行数:7,代码来源:ServerEntryThumbPersister.cs


示例2: GetProjectImage

        public static string GetProjectImage(string projectId, ImageSize imageType = ImageSize.Normal)
        {
            using (var session = MvcApplication.Store.OpenSession())
            {
                using (session.Advanced.DocumentStore.AggressivelyCacheFor(TimeSpan.FromMinutes(1000)))
                {
                    var project = session.Load<Project>(projectId);

                    if (project == null)
                        return NOIMAGE_URL;

                    if (project.Image == null)
                        return NOIMAGE_URL;

                    switch (imageType)
                    {
                        case ImageSize.Normal:
                            return string.IsNullOrEmpty(project.Image.Logo) ? NOIMAGE_URL : project.Image.Logo;
                        case ImageSize.Icon:
                            return string.IsNullOrEmpty(project.Image.Icon) ? NOIMAGE_URL : project.Image.Icon;
                        case ImageSize.Banner:
                            return string.IsNullOrEmpty(project.Image.Banner) ? NOIMAGE_URL : project.Image.Banner;
                        case ImageSize.BannerThumb:
                            return string.IsNullOrEmpty(project.Image.Banner) ? NOIMAGE_BANNER : project.Image.Thumbnail;
                    }
                }
            }

            return NOIMAGE_URL;
        }
开发者ID:ja1984,项目名称:ProjectZ,代码行数:30,代码来源:ImageUtils.cs


示例3: DownloadImage

        /// <summary>
        /// Download image.
        /// </summary>
        /// <param name="imagePath">The image path.</param>
        /// <param name="imageExtension">The image extension.</param>
        /// <param name="imageSize">The image size.</param>
        /// <param name="callback">The callback.</param>
        /// <returns>A coroutine.</returns>
        public IEnumerator DownloadImage(
            string imagePath,
            string imageExtension,
            ImageSize imageSize,
            Action<IResult<Texture2D>> callback)
        {
            string imageSizeURIPart = this.GetImageSize(imageSize);
            string requestUri = string.Concat(imagePath, "/", imageSizeURIPart, ".", imageExtension);

            WWW request = this.webRequestor.PerformGetRequest(requestUri);

            yield return request;

            IResult<Texture2D> result = null;

            if (request != null &&
                string.IsNullOrEmpty(request.error))
            {
                result = new Result<Texture2D>(request.texture);
            }
            else
            {
                result = new Result<Texture2D>(request.error);
            }

            callback(result);
        }
开发者ID:JonJam,项目名称:marveluniverse,代码行数:35,代码来源:ImageService.cs


示例4: GetDeviceImageAsync

        public Task<byte[]> GetDeviceImageAsync(string id, ImageSize size = ImageSize.Small)
        {
            if (string.IsNullOrEmpty(id))
                throw new ArgumentException("Device id is required");

            string action = Map[typeof(Device)];
            var request = GetRequest(Request(action, id, "image"), Method.GET);
            request.AddParameter("size", size);

            var tcs = new TaskCompletionSource<byte[]>();
            try
            {
                RestClient.ExecuteAsync(request, response =>
                    {
                        if (response.StatusCode == HttpStatusCode.OK)
                            tcs.SetResult(response.RawBytes);
                        else
                            tcs.SetResult(null);
                    });
            }
            catch(Exception ex)
            {
                tcs.SetException(ex);
            }
            return tcs.Task;
        }
开发者ID:NinjaButters,项目名称:Mojio.Client,代码行数:26,代码来源:MojioClient.Mojio.cs


示例5: ProductImage

 public static MvcHtmlString ProductImage(this HtmlHelper helper, string rawFile, ImageSize size, bool noCaching, object htmlAttributes)
 {
     var imgSizeIndicator = System.Enum.GetName(typeof(ImageSize), size);
     var imgFile = UrlHelper.GenerateContentUrl(string.Format("~/Images/Products/{0}", rawFile), helper.ViewContext.HttpContext);
     TagBuilder tb = new TagBuilder("img");
     if (noCaching)
         tb.MergeAttribute("src", imgFile + "?" + new Random().NextDouble().ToString(CultureInfo.InvariantCulture));
     else
         tb.MergeAttribute("src", imgFile);
     tb.MergeAttribute("border", "0");
     var sizeValue = 65;
     switch (size)
     {
         case ImageSize.Medium:
             sizeValue = 130;
             break;
         case ImageSize.Large:
             sizeValue = 195;
             break;
         default:
             break;
     }
     tb.MergeAttribute("width", sizeValue.ToString());
     tb.MergeAttribute("height", sizeValue.ToString());
     if (htmlAttributes != null)
     {
         IDictionary<string, object> additionAttributes = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes);
         tb.MergeAttributes<string, object>(additionAttributes);
     }
     return MvcHtmlString.Create(tb.ToString(TagRenderMode.SelfClosing));
 }
开发者ID:tiger2soft,项目名称:OnlineStore_One,代码行数:31,代码来源:HtmlExtension.cs


示例6: ImageThumb

        /// <summary>
        /// Returns an URL to entry thumbnail image.
        /// Currently only used for album and artist main images.
        /// 
        /// Gets the URL to the static images folder on disk if possible,
        /// otherwise gets the image from the DB.
        /// </summary>
        /// <param name="urlHelper">URL helper. Cannot be null.</param>
        /// <param name="imageInfo">Image information. Cannot be null.</param>
        /// <param name="size">Requested image size.</param>
        /// <param name="fullUrl">
        /// Whether the URL should always include the hostname and application path root.
        /// If this is false (default), the URL maybe either full (such as http://vocadb.net/Album/CoverPicture/123)
        /// or relative (such as /Album/CoverPicture/123).
        /// Usually this should be set to true if the image is to be referred from another domain.
        /// </param>
        /// <returns>URL to the image thumbnail.</returns>
        public static string ImageThumb(this UrlHelper urlHelper, IEntryImageInformation imageInfo, ImageSize size, bool fullUrl = false)
        {
            if (imageInfo == null)
                return null;

            var shouldExist = ShouldExist(imageInfo);
            string dynamicUrl = null;

            // Use MVC dynamic actions when requesting original or an image that doesn't exist on disk.
            if (imageInfo.EntryType == EntryType.Album) {

                if (size == ImageSize.Original)
                    dynamicUrl = urlHelper.Action("CoverPicture", "Album", new { id = imageInfo.Id, v = imageInfo.Version });
                else if (shouldExist && !imagePersister.HasImage(imageInfo, size))
                    dynamicUrl = urlHelper.Action("CoverPictureThumb", "Album", new { id = imageInfo.Id, v = imageInfo.Version });

            } else if (imageInfo.EntryType == EntryType.Artist) {

                if (size == ImageSize.Original)
                    dynamicUrl = urlHelper.Action("Picture", "Artist", new { id = imageInfo.Id, v = imageInfo.Version });
                else if (shouldExist && !imagePersister.HasImage(imageInfo, size))
                    dynamicUrl = urlHelper.Action("PictureThumb", "Artist", new { id = imageInfo.Id, v = imageInfo.Version });

            }

            if (dynamicUrl != null) {
                return (fullUrl ? AppConfig.HostAddress + dynamicUrl : dynamicUrl);
            }

            if (!shouldExist)
                return GetUnknownImageUrl(urlHelper, imageInfo);

            return imagePersister.GetUrlAbsolute(imageInfo, size, WebHelper.IsSSL(HttpContext.Current.Request));
        }
开发者ID:realzhaorong,项目名称:vocadb,代码行数:51,代码来源:UrlHelperExtenderForImages.cs


示例7: FromUrl

        public ImageLoadResults FromUrl(string url, bool ignoreRestrictions, ImageSize minSize, ImageSize maxSize, bool redownload)
        {
            // if this resource already exists
              if (File.Exists(Filename))
              {
            // if we are redownloading, just delete what we have
            if (redownload)
            {
              try
              {
            File.Delete(Filename);
            File.Delete(ThumbFilename);
              }
              catch (Exception) { }
            }
            // otherwise return an "already loaded" failure
            else
            {
              return ImageLoadResults.FAILED_ALREADY_LOADED;
            }
              }

              // try to grab the image if failed, exit
              if (!Download(url)) return ImageLoadResults.FAILED;

              // verify the image file and resize it as needed
              return VerifyAndResize(minSize, maxSize);
        }
开发者ID:andrewjswan,项目名称:mvcentral,代码行数:28,代码来源:ImageResource.cs


示例8: ShowDialog

 /// <summary>
 /// Show Dialog
 /// </summary>
 /// <param name="sender">sender control</param>
 /// <param name="resolution">image size</param>
 /// <returns>filepath of photo</returns>
 public static FileInfo ShowDialog(Control sender, ImageSize resolution)
 {
     if (SystemState.CameraPresent && SystemState.CameraEnabled)
     {
         using (CameraCaptureDialog cameraCaptureDialog = new CameraCaptureDialog())
         {
             cameraCaptureDialog.Owner = sender;
             cameraCaptureDialog.Mode = CameraCaptureMode.Still;
             cameraCaptureDialog.StillQuality = CameraCaptureStillQuality.Normal;
             cameraCaptureDialog.Title = "takeIncidentPhoto".Translate();
             if (resolution != null)
             {
                 cameraCaptureDialog.Resolution = resolution.ToSize();
             }
             if (cameraCaptureDialog.ShowDialog() == DialogResult.OK)
             {
                 return new FileInfo(cameraCaptureDialog.FileName);
             }
         }
     }
     else
     {
         using(OpenFileDialog openFileDialog = new OpenFileDialog())
         {
             openFileDialog.Filter = "JPEG (*.jpg,*.jpeg)|*.jpg;*.jpeg";
             if (openFileDialog.ShowDialog() == DialogResult.OK)
             {
                 return new FileInfo(openFileDialog.FileName);
             }
         }
     }
     return null;
 }
开发者ID:ushahidi,项目名称:Ushahidi_WinMobile,代码行数:39,代码来源:PhotoSelector.cs


示例9: Write

		public void Write(IEntryImageInformation picture, ImageSize size, Image image) {

			using (var stream = new MemoryStream()) {
				image.Save(stream, GetImageFormat(picture));
				Write(picture, size, stream);
			}

		}
开发者ID:realzhaorong,项目名称:vocadb,代码行数:8,代码来源:InMemoryImagePersister.cs


示例10: PoweredByCloudCore

        public static MvcHtmlString PoweredByCloudCore(this System.Web.Mvc.HtmlHelper helper, ImageSize imageSize)
        {
            var urlHelper = new System.Web.Mvc.UrlHelper(helper.ViewContext.RequestContext);
            
            string imageSourceUrl = urlHelper.Asset(string.Format("poweredby/{0}.png", imageSize), "CUI");

            return new MvcHtmlString(string.Format("<a href=\"http://www.exclr8.co.za/#cloudcore\" target=\"_blank\"><img style=\"border: 0\" src=\"{0}\" /></a>", imageSourceUrl));
        }
开发者ID:Exclr8,项目名称:CloudCore,代码行数:8,代码来源:PoweredBy.cs


示例11:

 public ImageInfo this[ImageSize index]
 {
     get { return _imageInfo[(int) index]; }
     private set
     {
         _imageInfo[(int) index] = value;
     }
 }
开发者ID:jorik041,项目名称:Haystack,代码行数:8,代码来源:InMemoryIndex.cs


示例12: AssertDimensions

		private void AssertDimensions(IEntryImageInformation imageInfo, ImageSize size, int width, int height) {

			using (var stream = persister.GetReadStream(imageInfo, size))
			using (var img = Image.FromStream(stream)) {
				Assert.AreEqual(width, img.Width, "Image width");
				Assert.AreEqual(height, img.Height, "Image height");
			}

		}
开发者ID:realzhaorong,项目名称:vocadb,代码行数:9,代码来源:ImageThumbGeneratorTests.cs


示例13: GetAlbumImageUri

        /// <summary>
        ///     Gets the Uri to the album's image at the given size
        /// </summary>
        /// <param name="albumId">Id representing the album with the desired image</param>
        /// <param name="size">Size of the image desired</param>
        /// <returns>Uri to the album's image at the given size</returns>
        public async Task<Uri> GetAlbumImageUri(string albumId, ImageSize size = ImageSize.Medium)
        {
            ValidateResourceId(albumId);

            var method = string.Format("albums/{0}/images/default", albumId);

            var response = await GetResourceImageUri(method, size);

            return response;
        }
开发者ID:UserNameBlin,项目名称:BeatsMusicCSharp,代码行数:16,代码来源:ImagesEndpoint.cs


示例14: GetPlaylistImageUri

        /// <summary>
        ///     Gets the Uri to the playlist's image at the given size
        /// </summary>
        /// <param name="playlistId">Id representing the playlist with the desired image</param>
        /// <param name="size">Size of the image desired</param>
        /// <returns>Uri to the playlist's image at the given size</returns>
        public async Task<Uri> GetPlaylistImageUri(string playlistId, ImageSize size = ImageSize.Medium)
        {
            ValidateResourceId(playlistId);

            var method = string.Format("playlists/{0}/images/default", playlistId);

            var response = await GetResourceImageUri(method, size);

            return response;
        }
开发者ID:UserNameBlin,项目名称:BeatsMusicCSharp,代码行数:16,代码来源:ImagesEndpoint.cs


示例15: Load

        public byte[] Load(int haystackId, long photoKey, ImageSize size, int cookie)
        {
            var idx = _inMemoryIndex.Get(photoKey);

            var offset = idx[size].Offset;

            var dataSize = idx[size].Size;

            return _haystackService.Read(idx.PhotoKey, (int) size, cookie, offset, dataSize);
        }
开发者ID:jorik041,项目名称:Haystack,代码行数:10,代码来源:PhotoStoreService.cs


示例16: UpdateAppWidget

        internal static void UpdateAppWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId)
        {
            RemoteViews views = new RemoteViews(context.PackageName, Resource.Layout.widget);

            ImageSize minImageSize = new ImageSize(70, 70); // 70 - approximate size of ImageView in widget
            ImageLoader.Instance
                    .LoadImage(Constants.IMAGES[0], minImageSize, displayOptions, new ThisSimpleImageLoadingListener(appWidgetManager, appWidgetId, views, Resource.Id.image_left));
            ImageLoader.Instance
                    .LoadImage(Constants.IMAGES[1], minImageSize, displayOptions, new ThisSimpleImageLoadingListener(appWidgetManager, appWidgetId, views, Resource.Id.image_right));
        }
开发者ID:wiyonoaten,项目名称:Android-Universal-Image-Loader,代码行数:10,代码来源:UILWidgetProvider.cs


示例17: ChessBoard

        public ChessBoard(Context context)
        {
            InitializeComponent();

            boardManager = new BoardManager(context);
            this.komaImageSize = context.Size;
            this.PictureSize = getImageSize();
            ClientSize = new Size(PictureSize * 8, PictureSize * 8);
            createKoma();
        }
开发者ID:kojikishiya,项目名称:Chess,代码行数:10,代码来源:ChessBoard.cs


示例18: GetTrackImageUri

        /// <summary>
        ///     Gets the Uri to the track's image at the given size
        /// </summary>
        /// <param name="trackId">Id representing the album with the desired image</param>
        /// <param name="size">Size of the image desired</param>
        /// <returns>Uri to the track's image at the given size</returns>
        public async Task<Uri> GetTrackImageUri(string trackId, ImageSize size = ImageSize.Medium)
        {
            ValidateResourceId(trackId);

            var method = string.Format("tracks/{0}/images/default", trackId);

            var response = await GetResourceImageUri(method, size);

            return response;
        }
开发者ID:UserNameBlin,项目名称:BeatsMusicCSharp,代码行数:16,代码来源:ImagesEndpoint.cs


示例19: GenerateThumbAndMoveImage

		/// <summary>
		/// Writes an image to a file, overwriting any existing file.
		/// 
		/// If the dimensions of the original image are smaller or equal than the thumbnail size,
		/// the file is simply copied. Otherwise it will be shrunk.
		/// </summary>
		/// <param name="original">Original image. Cannot be null.</param>
		/// <param name="input">Stream to be written. Cannot be null.</param>
		/// <param name="imageInfo">Image information. Cannot be null.</param>
		/// <param name="size">Image size of the saved thumbnail.</param>
		/// <param name="dimensions">Dimensions of the thumbnail.</param>
		private void GenerateThumbAndMoveImage(Image original, Stream input, IEntryImageInformation imageInfo, ImageSize size, int dimensions) {

			if (dimensions != Unlimited && (original.Width > dimensions || original.Height > dimensions)) {
				using (var thumb = ImageHelper.ResizeToFixedSize(original, dimensions, dimensions)) {
					persister.Write(imageInfo, size, thumb);
				}
			} else {
				persister.Write(imageInfo, size, input);
			}

		}
开发者ID:realzhaorong,项目名称:vocadb,代码行数:22,代码来源:ImageThumbGenerator.cs


示例20: BuildSrc

 /// <summary>
 /// returns "/img/{size}/default-{name}.{format}", "img/{size}/t{imageType}t{yearMonth}-{id}.{format}"
 /// </summary>
 /// <param name="key">
 /// t20t201410-6C294E0437664E3FA99C0CBAA4E8CCD1.png
 /// default-websitelogo.png
 /// </param>
 /// <param name="size"></param>
 /// <returns>
 /// e.g. /img/full/t20t201410-6C294E0437664E3FA99C0CBAA4E8CCD1.png
 /// e.g. /img/s80x80/t20t201410-6C294E0437664E3FA99C0CBAA4E8CCD1.png
 /// e.g. /img/s80x80/default-websitelogo.png
 /// </returns>
 public static string BuildSrc(string key, ImageSize size)
 {
     if (string.IsNullOrEmpty(key))
     {
         return "/_storage/css/404.png";
     }
     if (key.IndexOf("/", StringComparison.OrdinalIgnoreCase) == -1)
     {
         return string.Format("/img/{0}/{1}", size, key);
     }
     return key;
 }
开发者ID:yuandong618,项目名称:mvcsolution,代码行数:25,代码来源:ImageHelper.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ImageSource类代码示例发布时间:2022-05-24
下一篇:
C# ImageResource类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap