本文整理汇总了C#中System.Drawing.Bitmap.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# System.Drawing.Bitmap.ToArray方法的具体用法?C# System.Drawing.Bitmap.ToArray怎么用?C# System.Drawing.Bitmap.ToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Bitmap
的用法示例。
在下文中一共展示了System.Drawing.Bitmap.ToArray方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetImage
/// <summary>
/// Gets the image.
/// </summary>
/// <returns></returns>
public TourOperator.Models.Models.ImmagineCache GetImage(int w, int h, string id)
{
var image = _images.GetAll().Single(x => x.Id.ToString() == id);
w = (w == -1 ? image.MasterWidth : w);
h = (h == -1 ? image.MasterHeight : h);
if (image.Cache.Where(x => x.Height == h && x.Width == w).Any())
return image.Cache.Where(x => x.Height == h && x.Width == w).First();
// E' stata fatta una nuova richiesta
System.Drawing.Bitmap img = new System.Drawing.Bitmap(new System.IO.MemoryStream(image.Master));
ResamplingService resamplingService = new ResamplingService();
resamplingService.Filter = ResamplingFilters.Lanczos8;
ushort[][,] input = img.ToArray();
ushort[][,] output = resamplingService.Resample(input, w, h);
var imgCustom = output.ToBitmap();
// .. mettere qualche meccanismo di controllo
var ms = new System.IO.MemoryStream();
imgCustom.Save(ms, GetImageFormat(image.ContentType));
var imageBuffer = ms.ToArray();
// Salvo la nuova immagine nel database
var newImageCache = new TourOperator.Models.Models.ImmagineCache()
{
ETag = ETagCalc(imageBuffer),
Immagine = image,
ImageBlob = imageBuffer,
Width = w,
Height = h
};
image.Cache.Add(newImageCache);
_images.SaveOrUpdate(image);
return newImageCache;
}