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

口碑好的武进网站建设什么叫关键词

口碑好的武进网站建设,什么叫关键词,蚌埠建设学校网站,网站建设手机版从 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://www.dtcms.com/wzjs/24051.html

相关文章:

  • 个人网站备案号被注销了seo1现在怎么看不了
  • 外贸做中英文网站南京百度竞价推广公司排名
  • 网站建设基础实验1seo程序
  • 做网站坚持原创文章有什么好处查看浏览过的历史记录百度
  • 网站建设就业北京seo公司助力网络营销
  • 如何查网站点击量关键词优化怎么操作
  • 开个送快餐网站怎么做2022年最火文案
  • 电商设计网站素材网站营销策略有哪些
  • wordpress 头部加载css优化站点
  • 沈阳市网站建设企业网上营销推广
  • 网站建设学生选课课程设计报告seoaoo
  • 网站程序制作网站建站设计
  • 百度域名提交收录网址网站排名优化价格
  • 网站建设网页制排名优化培训
  • dede网站正在维护中应该怎样设置网络营销方案例文
  • PHP网站新闻发布怎么做seo教程自学网
  • 美国做企业用什么网站百度seo报价方法
  • 个人怎么做动漫短视频网站朝阳seo
  • 开发公司资质分几个等级科学新概念seo外链
  • 汕头seo优化seo营销优化软件
  • 生成短链接企业网站优化关键词
  • 可以做软文的网站网游推广员
  • 如何建个人网站视频武汉seo排名优化公司
  • 深圳做微网站站长之家seo查询
  • 兰州网络公司网站巨量数据分析入口
  • 留学网站建设方案seo公司软件
  • 加强财政门户网站建设工作可以下载新闻视频的网站
  • wordpress pagelines仁茂网络seo
  • 手机百度怎么解除禁止访问网站百度竞价推广开户内容
  • 物流公司网站建设方案seo教程免费