Example #1
0
 public PixelRectangleInfo(int width, int height, IPixelInformation pixelInfo, PixmapOrientation orient, int bytesPerRow)
 {
     Width = width;
     Height = height;
     Layout = pixelInfo.Layout;
     ComponentType = pixelInfo.ComponentType;
     Orientation = orient;
     Alignment = 1;
     BytesPerRow = bytesPerRow;
 }
Example #2
0
        public static ColorRGBA GetColor(IPixelInformation pixelInfo, IntPtr data, int startIndex)
        {
            int bytesPerPixel = pixelInfo.BytesPerPixel;


            // how many components are there?
            int nComponents = PixelInformation.GetComponentsPerLayout(pixelInfo.Layout);
            int componentSize = PixelInformation.GetBytesPerComponent(pixelInfo.ComponentType);
            double maxValue = PixelInformation.GetMaxComponentValue(pixelInfo.ComponentType);

            float[] floats = new float[nComponents];


            switch (pixelInfo.ComponentType)
            {
                case PixelComponentType.Byte:
                case PixelComponentType.UnsignedByte:
                    byte[] bufferb = new byte[nComponents];
                    Marshal.Copy(data, bufferb, 0, nComponents);
                    for (int i = 0; i < nComponents; i++)
                        floats[i] = (float)(bufferb[i] / maxValue);
                    break;

                case PixelComponentType.Short:
                    short[] buffers = new short[nComponents];
                    Marshal.Copy(data, buffers, 0, nComponents);
                    for (int i = 0; i < nComponents; i++)
                        floats[i] = (float)(buffers[i] / maxValue);
                    break;


                case PixelComponentType.Int:
                    int[] bufferi = new int[nComponents];
                    Marshal.Copy(data, bufferi, 0, nComponents);
                    for (int i = 0; i < nComponents; i++)
                        floats[i] = (float)(bufferi[i] / maxValue);
                    break;

                case PixelComponentType.Float:
                    int[] bufferf = new int[nComponents];
                    Marshal.Copy(data, bufferf, 0, nComponents);
                    for (int i = 0; i < nComponents; i++)
                        floats[i] = (float)(bufferf[i] / maxValue);
                    break;

                case PixelComponentType.Double:
                    int[] bufferd = new int[nComponents];
                    Marshal.Copy(data, bufferd, 0, nComponents);
                    for (int i = 0; i < nComponents; i++)
                        floats[i] = (float)(bufferd[i] / maxValue);
                    break;
            }

            ColorRGBA newColor = new ColorRGBA(floats);

            return newColor;
        }
Example #3
0
 public static ColorRGBA GetColor(IPixelInformation pixelInfo, byte[] data, int startIndex)
 {
     return GetColor(pixelInfo.Layout, pixelInfo.ComponentType, data, startIndex);
 }
Example #4
0
 public static ColorRGBA GetColor(IPixelInformation pixelInfo, byte[] data)
 {
     return GetColor(pixelInfo, data, 0);
 }
Example #5
0
 public static byte[] GetBytesForColor(IPixelInformation pInfo, ColorRGBA color)
 {
     return GetBytesForColor(pInfo.Layout, pInfo.ComponentType, color);
 }
Example #6
0
 protected PixelAccessor(int width, int height, IPixelInformation pixelInfo, int bytesPerRow, PixmapOrientation orientation,
     IntPtr pixelPointer)
 {
     PixRectInfo = new PixelRectangleInfo(width, height, pixelInfo, orientation, bytesPerRow);
     fPixelPointer = pixelPointer;
 }