zoukankan      html  css  js  c++  java
  • C#将像素值转换为图片

    int width = 50; 
    int height = 50; 
    var bitmap = new Bitmap(width, height, PixelFormat.Canonical);
     
    for (int y = 0; y < height; y++)
       for (int x = 0; x < width; x++)
       {
          int red = 0; 
          int green = 0; 
          int blue = 0; 
          bitmap.SetPixel(x, y, Color.FromArgb(0, red, green, blue));
       }

    ********************************************************************************************************

     private void button1_Click(object sender, EventArgs e)
            {
                Bitmap bmp = new Bitmap(700, 550);                      //改图只显示最近输入的700个点的数据曲线。
              //  Graphics graphics = Graphics.FromImage(bmp);
             //   SolidBrush brush1 = new SolidBrush(Color.FromArgb(255, 0, 0));
             //   graphics.FillRectangle(brush1, 0, 0, 700, 550);//Brushes.Sienna
                for(int i =0;i<bmp.Width;i++)
                    for(int j =0 ;j<bmp.Height;j++)
                    {
                        Color c = Color.FromArgb( (i/400)*255, (j/300)*255, 0);
                        bmp.SetPixel(i, j, c);
                    }
                bmp.Save("c:\11.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);//指定图片格式   
                bmp.Dispose();
            //    graphics.Dispose();
            //    brush1.Dispose();//一定释放内存。
            }


  • 相关阅读:
    sublimetext插件安装
    解决Nextcloud 无法删除目录
    常用文章信息
    使用豆瓣的pip源安装python模块
    top命令的使用
    Centos 7 防火墙 firewalld 简单使用说明
    CentOS 7 时间同步方法
    二进制
    字典
    集合
  • 原文地址:https://www.cnblogs.com/zztong/p/6695156.html
Copyright © 2011-2022 走看看