本文整理汇总了C#中System.Web.Helpers.WebImage.Write方法的典型用法代码示例。如果您正苦于以下问题:C# WebImage.Write方法的具体用法?C# WebImage.Write怎么用?C# WebImage.Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.Helpers.WebImage
的用法示例。
在下文中一共展示了WebImage.Write方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Thumbnail
public ActionResult Thumbnail(string id)
{
var repository = new TagRepository();
var tag = repository.GetTag(id);
var photoList = repository.GetPhotoList(id);
if (tag != null && photoList.Count > 0)
{
using (MultiThumbnailGenerator generator = new MultiThumbnailGenerator())
{
foreach (var photo in photoList)
{
using (var imageStream = new System.IO.MemoryStream(photo.FileContents))
{
using (var image = System.Drawing.Image.FromStream(imageStream))
{
generator.AddImage(image);
}
}
}
using (var outStream = new System.IO.MemoryStream())
{
generator.WritePngToStream(outStream);
var image = new WebImage(outStream);
image.Write();
}
}
return null;
}
return Redirect("~/Content/Images/gallery-empty.png");
}
示例2: GetImage
public void GetImage(string horizontalFlip="", string verticalFlip="",
string rotateLeft="", string rotateRight="")
{
var imagePath = Server.MapPath("~/images/bunny-peanuts.jpg");
var image = new WebImage(imagePath);
if (!string.IsNullOrWhiteSpace(verticalFlip))
image = image.FlipVertical();
if (!string.IsNullOrWhiteSpace(horizontalFlip))
image = image.FlipHorizontal();
if (!string.IsNullOrWhiteSpace(rotateLeft))
image = image.RotateLeft();
if (!string.IsNullOrWhiteSpace(rotateRight))
image = image.RotateRight();
image.Write();
}
示例3: GetResizeImage
//---------------------------------------------------------------------------------------------------
//--Изменят размер и обрезает изображение или просто изменяет размер---------------------------------
public void GetResizeImage(int id, int rWidth = 320, int rHeight = 320, int cWidth = 0, int cHeight = 0)
{
ImageDetails img = repository.Load(id);
WebImage wbImage = new WebImage(img.image);
wbImage.Resize(rWidth, rHeight); //--изменяем размер картинки--
int h = wbImage.Height, w = wbImage.Width;
wbImage.Crop(cHeight, cWidth, cHeight, cWidth); //--обрезаем картинку--
wbImage.FileName = img.title + ".jpg";
wbImage.Write();
}
示例4: GetCurrentImage
public void GetCurrentImage(string key)
{
WebImage wi = new WebImage(_worker.FileRepository.RetrieveAttachment(key));
wi.Write();
}
示例5: Thumbnail
public ActionResult Thumbnail(int id)
{
var db = new PhotoGalleryRepository();
var gallery = db.GetGallery(id);
if (gallery == null)
{
return HttpNotFound();
}
var photos = db.GetTopPhotosForGallery(id);
if (photos.Count == 0)
{
return File(Server.MapPath("~/Content/Images/gallery-empty.png"), "image/jpeg");
}
using (var generator = new MultiThumbnailGenerator())
{
foreach (var photo in photos)
{
using (var imageStream = new MemoryStream(photo.FileContents))
{
using (var image = System.Drawing.Image.FromStream(imageStream))
{
generator.AddImage(image);
}
}
}
using (var outStream = new MemoryStream())
{
generator.WritePngToStream(outStream);
var image = new WebImage(outStream);
image.Write();
return null;
}
}
}