zoukankan      html  css  js  c++  java
  • c#载入图片,修改图片的二进制数据

    上图片为rar合并图片,图片另存为后后缀改为rar,可以解压缩出项目。

    private void Form1_Paint(object sender, PaintEventArgs e)
            {
                Graphics g = e.Graphics;
                Bitmap bitmap = new Bitmap("p.png");//如果用png图片,格式是rgb,如果用大小如240,240,格式是rgba
                BitmapData data = bitmap.LockBits(new Rectangle(0, 0, 200, 200), System.Drawing.Imaging.ImageLockMode.ReadWrite, bitmap.PixelFormat);
                IntPtr start = data.Scan0;
    
                // Declare an array to hold the bytes of the bitmap.
                int bytes = Math.Abs(data.Stride) * bitmap.Height;
                byte[] rgbValues = new byte[bytes];
    
                // Copy the RGB values into the array.
                System.Runtime.InteropServices.Marshal.Copy(start, rgbValues, 0, bytes);
    
                // Set every third value to 255. A 24bpp bitmap will look red.  
                for (int counter = 2; counter < rgbValues.Length; counter += 3)
                    rgbValues[counter] = 255;
    
                // Copy the RGB values back to the bitmap
                System.Runtime.InteropServices.Marshal.Copy(rgbValues, 0, start, bytes);
    
                // Unlock the bits.
                bitmap.UnlockBits(data);
    
                g.DrawImage(bitmap, 0, 0, 200, 200);
    
    
            }
  • 相关阅读:
    WCF上传下载文件
    WCF使用相关
    .net WCF WF4.5 状态机、书签与持久化
    .net WCF WF4.5
    CSS小东西
    asp.net mvc导出execl_转载
    winform自定义控件开发
    html问题汇总
    工作中的小东西
    jQuery事件
  • 原文地址:https://www.cnblogs.com/wangjixianyun/p/2835383.html
Copyright © 2011-2022 走看看