当前位置: 首页 > wzjs >正文

养殖舍建设网站网站留言短信通知

养殖舍建设网站,网站留言短信通知,全网推广服务流程,linux可以做网站开发吗从 MVC 控制器内部创建位图图像并将其发送到浏览器;用 C# 编写并与 Linux 和 Windows 服务器兼容。 使用从 ASP.NET MVC 中的控制器下载任何文件类型File。 此示例创建一个位图 (jpeg) 并将其发送到浏览器。它需要 NuGet 包SixLabors.ImageSharp v1.0.4。 另请参…

        从 MVC 控制器内部创建位图图像并将其发送到浏览器;用 C# 编写并与 Linux 和 Windows 服务器兼容。

使用从 ASP.NET MVC 中的控制器下载任何文件类型File。

此示例创建一个位图 (jpeg) 并将其发送到浏览器。它需要 NuGet 包SixLabors.ImageSharp v1.0.4。

另请参阅:SixLabors.ImageSharp 图像实用程序类

另请参阅:将文件上传到浏览器后删除

下面的代码将创建以下四幅图像并在它们之间交替显示:

修改后的HomeController.cs文件: 

// HomeController.cs
using Microsoft.AspNetCore.Mvc;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;

namespace WebApplication1.Controllers
{
    public class HomeController : Controller
    {
        static private byte mod(int x, int y) // NOTE: only returns values 0 to 255
        {
            if ((y & 1) == 0) // NOTE: then base of 2 - no need for division
                return (byte)(x & (y - 1));
            else
                return (byte)(x % y);
        }
        static private void Image0(Image<Rgb24> bmp) // NOTE: this will create a colorful bitmap with colorful stars
        {
            // NOTE: loop through every pixel of the bitmap
            for (int x = 0; x < bmp.Width; x++)
                for (int y = 0; y < bmp.Height; y++)
                {
                    byte p = (byte)(x * y >> 8), c = mod(p, 3), z = 255; // NOTE: "z" can be any shade between 0 and 255
                    bmp[x, y] = new Rgb24(c == 0 ? p : z, c == 1 ? p : z, c == 2 ? p : z); // NOTE: set the color of the pixel at (x, y)
                }
        }
        static private void Image1(Image<Rgb24> bmp) // NOTE: this will create a bitmap with a pattern that repeats
        {
            // NOTE: loop through every pixel of the bitmap
            for (int x = 0; x < bmp.Width; x++)
                for (int y = 0; y < bmp.Height; y++)
                {
                    byte p = mod(x * y, 256), c = mod(p, 3), z = 0; // NOTE: "z" can be any shade between 0 and 255
                    bmp[x, y] = new Rgb24(c == 0 ? p : z, c == 1 ? p : z, c == 2 ? p : z); // NOTE: set the color of the pixel at (x, y)
                }
        }
        static private void Image2(Image<Rgb24> bmp) // NOTE: this will create a bitmap with a unique diagonal pattern
        {
            // NOTE: loop through every pixel of the bitmap
            for (int x = 0; x < bmp.Width; x++)
                for (int y = 0; y < bmp.Height; y++)
                {
                    byte p = mod(x, y), c = mod(p, 3), z = 127; // NOTE: "z" can be any shade between 0 and 255
                    bmp[x, y] = new Rgb24(c == 0 ? p : z, c == 1 ? p : z, c == 2 ? p : z); // NOTE: set the color of the pixel at (x, y)
                }
        }
        static private void Image3(Image<Rgb24> bmp) // NOTE: this will create a bitmap of noise
        {
            var rand = new Random();
            // NOTE: loop through every pixel of the bitmap
            for (int x = 0; x < bmp.Width; x++)
                for (int y = 0; y < bmp.Height; y++)
                {
                    byte p = mod(rand.Next(), 256), c = mod(p, 3), z = 255; // NOTE: "z" can be any shade between 0 and 255
                    bmp[x, y] = new Rgb24(c == 0 ? p : z, c == 1 ? p : z, c == 2 ? p : z); // NOTE: set the color of the pixel at (x, y)
                }
        }
        public IActionResult Index()
        {
            int image = int.Parse(Request.Cookies["image"] ?? "0");
            Response.Cookies.Append("image", (image + 1).ToString());
            const int shift = 9;
            const int width = 1 << shift, height = 1 << shift;
            using (var bmp = new Image<Rgb24>(width, height)) // NOTE: create 24-bit bitmap
            {
                switch (mod(image, 4))
                {
                    case 0:
                        Image0(bmp);
                        break;
                    case 1:
                        Image1(bmp);
                        break;
                    case 2:
                        Image2(bmp);
                        break;
                    case 3:
                        Image3(bmp);
                        break;
                }
                byte[] data;
                using (var ms = new MemoryStream())
                {
                    bmp.SaveAsJpeg(ms); // NOTE: save the bitmap as a JPEG image to the stream
                    data = ms.ToArray();

                }
                // NOTE: alternatively, send the data to the browser as a download with the file name "attachment.jpg" by uncommenting the following line
                // return File(data, System.Net.Mime.MediaTypeNames.Image.Jpeg, "attachment.jpg");

                return File(data, System.Net.Mime.MediaTypeNames.Image.Jpeg); // NOTE: send the data to the browser as a file of mime type "image/jpeg"
            }
        }
    }
}

如果您喜欢此文章,请收藏、点赞、评论,谢谢,祝您快乐每一天。


文章转载自:

http://Fe3JMc7V.hytfz.cn
http://kKYyRsBM.hytfz.cn
http://XAPKIr0n.hytfz.cn
http://2nK8WiMX.hytfz.cn
http://W4hCUqw3.hytfz.cn
http://g8JzEEUy.hytfz.cn
http://VKOD8PeM.hytfz.cn
http://cU0qvDhR.hytfz.cn
http://wbqvLLKR.hytfz.cn
http://co92mS7R.hytfz.cn
http://lyz6do0Q.hytfz.cn
http://SkAVVxNd.hytfz.cn
http://udMl3dLx.hytfz.cn
http://Fl6aB1Jx.hytfz.cn
http://StDlhQ7z.hytfz.cn
http://MQJH90a3.hytfz.cn
http://LdvXGlVz.hytfz.cn
http://8H2PdaPb.hytfz.cn
http://5WalX9Ok.hytfz.cn
http://qhj4OCsv.hytfz.cn
http://Ts37HGE8.hytfz.cn
http://lfbt03D2.hytfz.cn
http://uQiHsknk.hytfz.cn
http://rZVyvzXZ.hytfz.cn
http://AnZpxe7A.hytfz.cn
http://zeVe6c64.hytfz.cn
http://gZ6DIJEM.hytfz.cn
http://yOnPpjoh.hytfz.cn
http://B0tcJH6q.hytfz.cn
http://m33Chkv6.hytfz.cn
http://www.dtcms.com/wzjs/631613.html

相关文章:

  • 黑龙江省建设银行网站海口建设企业网站
  • 易书网上书城网站建设方案企业网站运营外包费用
  • 网站静态和动态区别网建网络科技有限公司
  • 做游戏代练去那个网站wordpress改了固定链接访问不
  • 3e网站建设专业网页制作室
  • 陕西网站建设的内容网络推广简短广告语
  • 那些做电影视频网站的赚钱吗次世代建模培训
  • 网站建设工作室+怎么样后缀的域名暂无法进行网站备案
  • 多用户自助建站关联词有哪些三年级
  • 上海做兼职网站有吗广告软文范例
  • 最好的网站开发公司wordpress responsive theme
  • 优化网站排名炉石吐司做的网站
  • 宿州品牌网站建设公司教做发型的网站
  • 陕西建设主管部门网站汕头模板建站代理
  • 唐山快速建站公司免费网站赚钱
  • 临海最火自适应网站建设wordpress nana
  • 青岛网站排名外包电商网站制作教程
  • 太原电商网站设计安康微平台
  • 网站建设淄博夸网站做的好怎么夸
  • 南阳网站推广方案百度seo规则最新
  • 做直播信号网站百度怎样发布信息
  • 合阳县建设局网站深圳宝安网站设计
  • 百度手机网站提交西宁市网站建设官网
  • 网站开发的运行可行性ppt网站建设
  • 基于asp的医疗网站开发dedecms 网站搬家
  • 网站都可以做哪些主题松岗建网站
  • 编织网站建设润才网站建设
  • 邯郸网站建设好的公司国家信息公示网
  • 怎么做淘宝客优惠券网站做一个什么网站好
  • 陕西专业做网站广州网络公关公司