本文整理汇总了C#中ImageSize类的典型用法代码示例。如果您正苦于以下问题:C# ImageSize类的具体用法?C# ImageSize怎么用?C# ImageSize使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ImageSize类属于命名空间,在下文中一共展示了ImageSize类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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));
}
示例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;
}
示例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);
}
示例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;
}
示例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));
}
示例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));
}
示例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);
}
示例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;
}
示例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);
}
}
示例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));
}
示例11:
public ImageInfo this[ImageSize index]
{
get { return _imageInfo[(int) index]; }
private set
{
_imageInfo[(int) index] = value;
}
}
示例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");
}
}
示例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;
}
示例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;
}
示例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);
}