Aardvark.Base.PixImage.GetLockFormat(System.Drawing.Imaging.PixelFormat)

Here are the examples of the csharp api class Aardvark.Base.PixImage.GetLockFormat(System.Drawing.Imaging.PixelFormat) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Example 7

1. Example

Project: aardvark.base
Source File: PixImageBitmap.cs
protected static PixImage CreateRawBitmap(System.Drawing.Bitmap bitmap)
        {
            var sdipf = GetLockFormat(bitmap.PixelFormat);
            var pfc = s_pixFormatAndCountOfPixelFormatBitmap[sdipf];

            var sx = bitmap.Width;
            var sy = bitmap.Height;
            var ch = pfc.E1;

            var pixImage = Create(pfc.E0, sx, sy, ch);
            var array = pixImage.Array;

            if (pfc.E0.Format == Col.Format.BW)
            {
                var bitImage = new PixImage<byte>(Col.Format.BW, 1 + (sx - 1) / 8, sy, 1);

                System.Drawing.Imaging.BitmapData bdata = bitmap.LockBits(
                    new System.Drawing.Rectangle(0, 0, sx, sy),
                    System.Drawing.Imaging.ImageLockMode.ReadOnly, sdipf);

                bdata.Scan0.CopyTo(bitImage.Volume.Data);

                bitmap.UnlockBits(bdata);
                ExpandPixels(bitImage, pixImage.ToPixImage<byte>());
            }
            else
            {
                System.Drawing.Imaging.BitmapData bdata = bitmap.LockBits(
                    new System.Drawing.Rectangle(0, 0, sx, sy),
                    System.Drawing.Imaging.ImageLockMode.ReadOnly, sdipf);

                bdata.Scan0.CopyTo(array);
                bitmap.UnlockBits(bdata);
            }
            return pixImage;
        }