示例#1
0
        public void InitDefaultColorModel()
        {
            bool success = wgDB.GetAllColorModels();

            if (success)
            {
                if (wgDB.m_colorModelList.Count() > 0)
                {
                    ColorModelContainer model        = wgDB.m_colorModelList[0];
                    ColorModel          m_colorModel = new ColorModel(model.Description, model.MaxPixelValue, model.GradientSize);


                    for (int i = 0; i < model.Stops.Count(); i++)
                    {
                        m_colorModel.InsertColorStop(model.Stops[i].ColorIndex,
                                                     model.Stops[i].Red,
                                                     model.Stops[i].Green,
                                                     model.Stops[i].Blue);
                    }

                    m_colorModel.BuildColorGradient();
                    m_colorModel.BuildColorMap();

                    SetColorModel(m_colorModel);

                    DrawColorGradient();
                    DrawColorMap();
                }
            }
        }
示例#2
0
        public WriteableBitmap BuildColorMapBitmap(ColorModelContainer modelContainer)
        {
            WriteableBitmap bmap = BitmapFactory.New(100, modelContainer.GradientSize);

            ColorModel model = new ColorModel(modelContainer.Description, modelContainer.MaxPixelValue, modelContainer.GradientSize);

            for (int i = 0; i < modelContainer.Stops.Count(); i++)
            {
                model.InsertColorStop(modelContainer.Stops[i].ColorIndex, modelContainer.Stops[i].Red, modelContainer.Stops[i].Green, modelContainer.Stops[i].Blue);
            }

            model.BuildColorGradient();

            Color color = new Color();

            color.A = 255;

            for (int i = 0; i < model.m_gradientSize; i++)
            {
                color.R = model.m_gradient[i].m_red;
                color.G = model.m_gradient[i].m_green;
                color.B = model.m_gradient[i].m_blue;

                bmap.DrawLine(0, model.m_gradientSize - i, 100, model.m_gradientSize - i, color);
            }


            return(bmap);
        }
示例#3
0
        public ColorModel(ColorModelContainer cModelCont, int maxPixelValue = 65535, int gradientSize = 1024)
        {
            m_description  = cModelCont.Description;
            m_gradientSize = gradientSize;
            m_gain         = 1.0;

            m_controlPts = new ObservableCollection <ColorControlPoint>();
            m_stops      = new ObservableCollection <ColorStop>();

            m_gradient = new WG_Color[m_gradientSize];

            for (int i = 0; i < m_gradientSize; i++)
            {
                m_gradient[i] = new WG_Color(0, 0, 0);
            }

            foreach (ColorModelControlPointContainer pc in cModelCont.ControlPts)
            {
                m_controlPts.Add(new ColorControlPoint(pc.Value, pc.ColorIndex));
            }

            foreach (ColorModelStopContainer sc in cModelCont.Stops)
            {
                m_stops.Add(new ColorStop(sc.ColorIndex, new WG_Color(sc.Red, sc.Green, sc.Blue)));
            }

            //SetMaxPixelValue(maxPixelValue);
            m_maxPixelValue = maxPixelValue;
            m_colorMap      = new WG_Color[m_maxPixelValue + 1];

            for (int i = 0; i < m_maxPixelValue + 1; i++)
            {
                m_colorMap[i] = new WG_Color(0, 0, 0);
            }

            BuildColorGradient();

            BuildColorMap();
        }