Beispiel #1
0
        private Bitmap GetBitmapByte(double min, double max, ScaleMap scale, int z)
        {
            byte[] buf    = (byte[])DataBuffer;
            double factor = max - min;
            int    stride = AxisSize[0];
            int    page   = AxisSize[0] * AxisSize[1] * z;
            Bitmap bmp    = Bitmap.Create(AxisSize[0], AxisSize[1]);

            for (int y = 0; y < AxisSize[1]; y++)
            {
                int indexY = ((AxisSize[1] - 1) - y);

                for (int x = 0; x < AxisSize[0]; x++)
                {
                    if (color)
                    {
                        int datR = buf[(x + indexY * stride)];
                        int datG = buf[(x + indexY * stride) + page];
                        int datB = buf[(x + indexY * stride) + page * 2];
                        if (ContainsBlanks && (double)datR == BlankValue)
                        {
                            bmp.SetPixel(x, y, 0, 0, 0, 0);
                        }
                        else
                        {
                            int r = scale.Map(datR);
                            int g = scale.Map(datG);
                            int b = scale.Map(datB);
                            bmp.SetPixel(x, y, r, g, b, 255);
                        }
                    }
                    else
                    {
                        int dataValue = buf[x + indexY * stride + page];
                        if (ContainsBlanks && (double)dataValue == BlankValue)
                        {
                            bmp.SetPixel(x, y, 0, 0, 0, 0);
                        }
                        else
                        {
                            Byte val = scale.Map(dataValue);

                            bmp.SetPixel(x, y, val, val, val, (TransparentBlack && val == 0) ? 0 : 255);
                        }
                    }
                }
            }
            return(bmp);
        }
Beispiel #2
0
        public Bitmap GetBitmapShort(double min, double max, ScaleMap scale, int z, ColorMapContainer colorMapper)
        {
            short[] buf    = (short[])DataBuffer;
            double  factor = max - min;
            int     stride = AxisSize[0];
            int     page   = AxisSize[0] * AxisSize[1] * z;
            Bitmap  bmp    = Bitmap.Create(AxisSize[0], AxisSize[1]);

            for (int y = 0; y < AxisSize[1]; y++)
            {
                int indexY = ((AxisSize[1] - 1) - y);

                for (int x = 0; x < AxisSize[0]; x++)
                {
                    if (color)
                    {
                        int datR = buf[(x + indexY * stride)];
                        int datG = buf[(x + indexY * stride) + page];
                        int datB = buf[(x + indexY * stride) + page * 2];
                        if (ContainsBlanks && (double)datR == BlankValue)
                        {
                            bmp.SetPixel(x, y, 0, 0, 0, 0);
                        }
                        else
                        {
                            int r = scale.Map(datR);
                            int g = scale.Map(datG);
                            int b = scale.Map(datB);
                            bmp.SetPixel(x, y, r, g, b, 255);
                        }
                    }
                    else
                    {
                        int dataValue = buf[x + indexY * stride + page];
                        if (ContainsBlanks && (double)dataValue == BlankValue)
                        {
                            bmp.SetPixel(x, y, 0, 0, 0, 0);
                        }
                        else
                        {
                            Byte val = scale.Map(dataValue);
                            SetPixelWithColorMap(bmp, x, y, val, colorMapper);
                        }
                    }
                }
            }
            return(bmp);
        }