예제 #1
0
        private Bitmap combineBitmaps(ProgressForm pf)
        {
            double[] map1 = loadHeightValuesFromData(mcop.map1Path);
            double[] map2 = loadHeightValuesFromData(mcop.map2Path);

            double[] finalMap = new double[map1.Length];

            bool shouldNormalize = mcop.normalize;

            clarity = mcop.clarity;

            ct = mcop.colorTone;

            setComboFunc();

            Bitmap combinedBitmap = new Bitmap(Width, Height);

            double min = double.MaxValue;
            double max = double.MinValue;

            double map1OpacityFinal = mcop.map1UsingOpacity ? mcop.map1Opacity : 1;
            double map2OpacityFinal = mcop.map2UsingOpacity ? mcop.map2Opacity : 1;

            for (int i = 0; i < Width; i++)
            {
                for (int j = 0; j < Height; j++)
                {
                    double a = map1[i * Height + j] * map1OpacityFinal;
                    double b = map2[i * Height + j] * map2OpacityFinal;

                    finalMap[i * Height + j] = comboFunc(a, b);

                    if (finalMap[i * Height + j] < min)
                    {
                        min = finalMap[i * Height + j];
                    }
                    if (finalMap[i * Height + j] > max)
                    {
                        max = finalMap[i * Height + j];
                    }
                }

                if (pf != null)
                {
                    pf.ProgressBarValue += Height;
                }
            }

            pixels = new MapPixel[Width * Height];

            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    if (shouldNormalize)
                    {
                        finalMap[i * Height + j] = normalize(finalMap[i * Height + j], min, max);
                        pixels[i * Height + j]   = new MapPixel(i, j, finalMap[i * Height + j]);
                    }

                    combinedBitmap.SetPixel(i, j, ColorScheme.assignColorFromValue(finalMap[i * Height + j], ct, clarity));
                }

                if (pf != null)
                {
                    pf.ProgressBarValue += Height;
                }
            }

            return(combinedBitmap);
        }