Ejemplo n.º 1
0
        static Bitmap ColorToBitmap(int w, int h, Color[] argb)
        {
            //WL("argb.Length = "+argb.Length+" buff = "+buffer.Length);
            Bitmap     bmp  = new Bitmap(w, h, PixelFormat.Format32bppArgb);
            LockBitmap lbmp = new LockBitmap(bmp);

            lbmp.LockBits();
            for (int hi = 0; hi < h; hi++)
            {
                for (int wi = 0; wi < w; wi++)
                {
                    Color c = argb[hi * w + wi];
                    lbmp.SetPixel(wi, hi, c);
                }
            }
            lbmp.UnlockBits();
            return(bmp);
        }
Ejemplo n.º 2
0
        static byte[] RawGreyToImage(int w, int h, byte[] buffer)
        {
            Bitmap     bmp  = new Bitmap(w, h, PixelFormat.Format32bppArgb);
            LockBitmap lbmp = new LockBitmap(bmp);

            lbmp.LockBits();
            for (int b = 0; b < buffer.Length; b += 2)
            {
                int  pi = b * 2;              //for every 2 gray bytes we write 4 argb bytes
                byte c  = (byte)BitConverter.ToInt16(buffer, b);
                lbmp.Pixels[pi]     = c;
                lbmp.Pixels[pi + 1] = c;
                lbmp.Pixels[pi + 2] = c;
                lbmp.Pixels[pi + 3] = 255;               //a
            }
            lbmp.UnlockBits();

            MemoryStream s = new MemoryStream();

            bmp.Save(s, ImageFormat.Jpeg);
            return(s.ToArray());
        }
Ejemplo n.º 3
0
        static byte[] RawGreyToImage(int w,int h,byte[] buffer)
        {
            Bitmap bmp = new Bitmap(w, h, PixelFormat.Format32bppArgb);
            LockBitmap lbmp = new LockBitmap(bmp);
            lbmp.LockBits();
            for(int b=0; b<buffer.Length;b+=2) {
                int pi = b*2; //for every 2 gray bytes we write 4 argb bytes
                byte c = (byte)BitConverter.ToInt16(buffer,b);
                lbmp.Pixels[pi] = c;
                lbmp.Pixels[pi+1] = c;
                lbmp.Pixels[pi+2] = c;
                lbmp.Pixels[pi+3] = 255; //a
            }
            lbmp.UnlockBits();

            MemoryStream s = new MemoryStream();
            bmp.Save(s,ImageFormat.Jpeg);
            return s.ToArray();
        }
Ejemplo n.º 4
0
 static Bitmap ColorToBitmap(int w,int h, Color[] argb)
 {
     //WL("argb.Length = "+argb.Length+" buff = "+buffer.Length);
     Bitmap bmp = new Bitmap(w, h, PixelFormat.Format32bppArgb);
     LockBitmap lbmp = new LockBitmap(bmp);
     lbmp.LockBits();
     for (int hi = 0; hi < h; hi++)
     {
         for (int wi = 0; wi < w; wi++)
         {
             Color c = argb[hi * w + wi];
             lbmp.SetPixel(wi, hi, c);
         }
     }
     lbmp.UnlockBits();
     return bmp;
 }