本文整理汇总了C#中ImageInfo类的典型用法代码示例。如果您正苦于以下问题:C# ImageInfo类的具体用法?C# ImageInfo怎么用?C# ImageInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ImageInfo类属于命名空间,在下文中一共展示了ImageInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Animate
public static void Animate(Image image, EventHandler onFrameChangedHandler)
{
if (image != null)
{
ImageInfo item = null;
lock (image)
{
item = new ImageInfo(image);
}
StopAnimate(image, onFrameChangedHandler);
bool isReaderLockHeld = rwImgListLock.IsReaderLockHeld;
LockCookie lockCookie = new LockCookie();
threadWriterLockWaitCount++;
try
{
if (isReaderLockHeld)
{
lockCookie = rwImgListLock.UpgradeToWriterLock(-1);
}
else
{
rwImgListLock.AcquireWriterLock(-1);
}
}
finally
{
threadWriterLockWaitCount--;
}
try
{
if (item.Animated)
{
if (imageInfoList == null)
{
imageInfoList = new List<ImageInfo>();
}
item.FrameChangedHandler = onFrameChangedHandler;
imageInfoList.Add(item);
if (animationThread == null)
{
animationThread = new Thread(new ThreadStart(ImageAnimator.AnimateImages50ms));
animationThread.Name = typeof(ImageAnimator).Name;
animationThread.IsBackground = true;
animationThread.Start();
}
}
}
finally
{
if (isReaderLockHeld)
{
rwImgListLock.DowngradeFromWriterLock(ref lockCookie);
}
else
{
rwImgListLock.ReleaseWriterLock();
}
}
}
}
示例2: GetImages
public async Task<ImageInfo[]> GetImages(Match match)
{
var id = match.Groups[1].Value;
var key = "cloudapp-" + id;
var result = await this._memoryCache.GetOrSet(
"cloudapp-" + id,
() => this.Fetch(match.Value)
).ConfigureAwait(false);
ImageInfo i;
switch (result.item_type)
{
case "image":
i = new ImageInfo(result.content_url, result.content_url, result.thumbnail_url ?? result.content_url);
break;
case "video":
// ThumbnailUrl is probably null.
i = new ImageInfo(result.thumbnail_url, result.thumbnail_url, result.thumbnail_url, result.content_url, result.content_url, result.content_url);
break;
default:
throw new NotPictureException();
}
return new[] { i };
}
示例3: Product
public Product(string name, decimal unitPrice, Category category, ImageInfo image)
{
this.Name = name;
this.UnitPrice = unitPrice;
this.Category = category;
this.Image = image;
}
示例4: AttachedImage
public AttachedImage(PlatformClient client, AttachedImageData data)
: base(client)
{
_data = data;
Image = new ImageInfo(client, data.Image);
Album = new AlbumInfo(client, data.Album);
}
示例5: toImgur
public static ImageInfo toImgur(Bitmap bmp)
{
ImageConverter convert = new ImageConverter();
byte[] toSend = (byte[])convert.ConvertTo(bmp, typeof(byte[]));
using (WebClient wc = new WebClient())
{
NameValueCollection nvc = new NameValueCollection
{
{ "image", Convert.ToBase64String(toSend) }
};
wc.Headers.Add("Authorization", Imgur.getAuth());
ImageInfo info = new ImageInfo();
try
{
byte[] response = wc.UploadValues("https://api.imgur.com/3/upload.xml", nvc);
string res = System.Text.Encoding.Default.GetString(response);
var xmlDoc = new System.Xml.XmlDocument();
xmlDoc.LoadXml(res);
info.link = new Uri(xmlDoc.SelectSingleNode("data/link").InnerText);
info.deletehash = xmlDoc.SelectSingleNode("data/deletehash").InnerText;
info.id = xmlDoc.SelectSingleNode("data/id").InnerText;
info.success = true;
}
catch (Exception e)
{
info.success = false;
info.ex = e;
}
return info;
}
}
示例6: GetImages
public async Task<ImageInfo[]> GetImages(Match match)
{
var username = match.Groups[1].Value;
var id = match.Groups[2].Value;
var info = await this._memoryCache.GetOrSet(
"hatenafotolife-" + username + "/" + id,
() => this.Fetch(username, id)
).ConfigureAwait(false);
var result = new ImageInfo();
var baseUri = "http://cdn-ak.f.st-hatena.com/images/fotolife/" + username.Substring(0, 1) + "/" + username + "/" + id.Substring(0, 8) + "/" + id;
if (info.Extension == "flv")
{
result.VideoFull = result.VideoLarge = result.VideoMobile = baseUri + ".flv";
result.Full = result.Large = baseUri + ".jpg";
}
else
{
result.Large = baseUri + "." + info.Extension;
result.Full = info.IsOriginalAvailable
? baseUri + "_original." + info.Extension
: result.Large;
}
result.Thumb = baseUri + "_120.jpg";
return new[] { result };
}
示例7: _timer_Tick
void _timer_Tick(object sender, object e)
{
_timer.Stop();
ImageInfo image = new ImageInfo();
image.ViewBounds = this.ViewBounds;
StartDownloadImage(image);
}
示例8: DoIt
public void DoIt()
{
// Get the tool GUID;
Type t = typeof(SimpleTool);
GuidAttribute guidAttr = (GuidAttribute)t.GetCustomAttributes(typeof(GuidAttribute), false)[0];
Guid guid = new Guid(guidAttr.Value);
// don't redefine the stock tool if it's already in the catalog
ToolPaletteManager mgr = ToolPaletteManager.Manager;
if (mgr.StockToolCatalogs.Find(guid) != null)
return;
SimpleTool tool = new SimpleTool();
tool.New();
Catalog catalog = tool.CreateStockTool("SimpleCatalog");
Palette palette = tool.CreatePalette(catalog, "SimplePalette");
Package package = tool.CreateShapeCatalog("*AutoCADShapes");
tool.CreateFlyoutTool(palette, package, null);
ImageInfo imageInfo = new ImageInfo();
imageInfo.ResourceFile = "TOOL1.bmp";
imageInfo.Size=new System.Drawing.Size(65,65);
tool.CreateCommandTool(palette, "Line", imageInfo, tool.CmdName);
tool.CreateTool(palette, "Custom Line",imageInfo);
mgr.LoadCatalogs();
}
示例9: ResizeAsync
/// <summary>
/// Resizes the image presented by the <paramref name="imageData"/> to a <paramref name="newSize"/>.
/// </summary>
/// <param name="imageData">
/// The binary data of the image to resize.
/// </param>
/// <param name="newSize">
/// The size to which to resize the image.
/// </param>
/// <param name="keepAspectRatio">
/// A flag indicating whether to save original aspect ratio.
/// </param>
/// <returns>
/// The structure which contains binary data of resized image and the actial size of resized image depending on <paramref name="keepAspectRatio"/> value.
/// </returns>
/// <exception cref="InvalidOperationException">
/// An error occurred during resizing the image.
/// </exception>
public static Task<ImageInfo> ResizeAsync(this byte[] imageData, Size newSize, bool keepAspectRatio)
{
var result = new ImageInfo();
var image = imageData.ToBitmap();
var percentWidth = (double) newSize.Width/(double) image.PixelWidth;
var percentHeight = (double) newSize.Height/(double) image.PixelHeight;
ScaleTransform transform;
if (keepAspectRatio)
{
transform = percentWidth < percentHeight
? new ScaleTransform {ScaleX = percentWidth, ScaleY = percentWidth}
: new ScaleTransform {ScaleX = percentHeight, ScaleY = percentHeight};
}
else
{
transform = new ScaleTransform {ScaleX = percentWidth, ScaleY = percentHeight};
}
var resizedImage = new TransformedBitmap(image, transform);
using (var memoryStream = new MemoryStream())
{
var jpegEncoder = new JpegBitmapEncoder();
jpegEncoder.Frames.Add(BitmapFrame.Create(resizedImage));
jpegEncoder.Save(memoryStream);
result.Data = memoryStream.ToArray();
result.Size = new Size(resizedImage.PixelWidth, resizedImage.PixelHeight);
}
return Task.FromResult(result);
}
示例10: ProductImageReturnTheType
public void ProductImageReturnTheType()
{
ImageInfo imageInfo = new ImageInfo("Bike01.jpg");
string type = imageInfo.ImageType;
Assert.AreEqual("jpg", type);
}
示例11: ResizeImageAction
public ResizeImageAction(ImageInfo imageInfo, int oldWidth, int oldHeight, int newWidth, int newHeight)
{
this.imageInfo = imageInfo;
this.oldWidth = oldWidth;
this.oldHeight = oldHeight;
this.newWidth = newWidth;
this.newHeight = newHeight;
}
示例12: GetImageInfo
public static OpenCLErrorCode GetImageInfo(IMemoryObject image,
ImageInfo paramName,
IntPtr paramValueSize,
InfoBuffer paramValue,
out IntPtr paramValueSizeRet)
{
return clGetImageInfo((image as IHandleData).Handle, paramName, paramValueSize, paramValue.Address, out paramValueSizeRet);
}
示例13: AfterSetUp
protected override void AfterSetUp()
{
_product = new ProductBuilder().Build();
_image1 = new ImageInfo("1.png", ImageType.Png);
_image2 = new ImageInfo("2.jpg", ImageType.Jpeg);
_product.Images.Add(_image1);
_product.Images.Add(_image2);
Session.Save(_product);
}
示例14: StartDownloadImage
void StartDownloadImage(ImageInfo image)
{
CancelRequest();
_cts = new CancellationTokenSource();
Task.Run(async () =>
{
await DownloadImage(image, _cts.Token);
});
}
示例15: GenerateCrop
private static void GenerateCrop(Preset preset, string imgUrl, Config config, StringBuilder sbRaw)
{
if (string.IsNullOrEmpty(preset.Name))
return;
var imgInfo = new ImageInfo(imgUrl);
var data = new SaveData(sbRaw.ToString());
imgInfo.GenerateThumbnails(data, config);
}