从外部asp.net 3.5生成图像 [英] Generate an image from outstream asp.net 3.5

查看:107
本文介绍了从外部asp.net 3.5生成图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public static void ProcessDirectory(string targetDirectory)
   {

       // string[] fileEntries = Directory.GetFiles(targetDirectory, "*.jpg");
       var fileEntries = Directory.GetFiles(targetDirectory, "*.jpg");
       //if (photos.Count() == 0)
       //{
       //    Response.Redirect("~/Images/gallery-empty.png");
       //    return;
       //}
       // Process the list of files found in the directory.



       using (var generator = new MultiThumbnailGenerator())
       {
           foreach (var photo in fileEntries)
           {
               using (var imageStream = new System.IO.MemoryStream(photo.FileContents)) //error
               {
                   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();
           }
       }
   }







* MultiThumbnailGenerator是一个类,我正在生成该文件夹的许多图像的缩略图,在该缩略图中所有图像都轻轻显示,,,





我有一个外流(用于开发图像的许多图像),我用谷歌搜索它但我的要求是ASP.net 3.5。



如何生成,创建,将outstream保存为图像




*MultiThumbnailGenerator is a class where i am generating thumbnail of many images of the folder , in that thumbnail all the images have lightly display,,,


I have an outstream (of many images to develop an image) ,I googled it but my requirement is ASP.net 3.5.

how to generate,create,save the outstream as an image

推荐答案

这在很长一段时间内没有改变。我不知道ASP.NET 4中有什么新东西,我在1.1中做了这个。您创建一个HTTP处理程序,并在处理程序处理的URL上传递一个id。该ID告诉您在数据库中查找的图像。您将这些字节写入输出流。您的浏览器使用URL访问图像,并获取图像的字节。
This has not changed in how it works for a long time. I don''t see how there could be anything new in ASP.NET 4, I did this in 1.1. You create a HTTP handler and on the URL that handler processes, you pass an id. That id tells you what image to look up in your DB. You write those bytes to the output stream. Your browser uses the URL to access the image, and gets back the bytes of the image.


这篇关于从外部asp.net 3.5生成图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆