Beispiel #1
0
 public unsafe Bitmap Draw(GeoCalcBound bound, List<GeoRasterStyle> styles, int transparency, GeoTransformation transfor, HeightStyle heightStyle)
 {
     Bitmap bitmap;
     int key = this.DrawContextGetHashCode(bound, styles, transparency, heightStyle);
     if (!this.m_Cache.TryGetBitmap(key, out bitmap))
     {
         bitmap = new Bitmap(bound.RectColumns, bound.RectRows, PixelFormat.Format8bppIndexed);
         this.SetPalette(bitmap, styles, transparency, heightStyle);
         short[] valueByCalcBound = this.m_HeightData.GetValueByCalcBound<short>(bound, true);
         Rectangle rect = new Rectangle(0, 0, bitmap.Width, bitmap.Height);
         BitmapData bitmapdata = bitmap.LockBits(rect, ImageLockMode.ReadWrite, bitmap.PixelFormat);
         byte* numPtr = (byte*) bitmapdata.Scan0.ToPointer();
         int num2 = bitmapdata.Stride - bitmap.Width;
         List<MaxMinValue> heightIntervals = this.GetHeightIntervals(styles);
         for (int i = 0; i < bound.RectRows; i++)
         {
             for (int j = 0; j < bound.RectColumns; j++)
             {
                 short heightValue = valueByCalcBound[(bound.RectColumns * i) + j];
                 numPtr++;
                 numPtr[0] = (byte) ColorArray<short>.GetHeightIndexOfPalette(heightIntervals, heightValue, heightStyle);
             }
             numPtr += num2;
         }
         bitmap.UnlockBits(bitmapdata);
         this.GrayBitmap(bitmap, styles, heightStyle);
         this.m_Cache.UpdateCache(key, bitmap);
     }
     return bitmap;
 }
        public object ToJsObject()
        {
            var jObj = this.ToDynamic();

            if (!Script.IsNaN(Classes))
            {
                jObj.classes = Classes.ToJsDynamic();
            }
            if (!Script.IsNaN(Event))
            {
                jObj["event"] = Event.ToString();
            }
            if (!Script.IsNaN(HeightStyle))
            {
                jObj.heightStyle = HeightStyle.ToString();
            }
            if (!Script.IsNaN(Hide))
            {
                jObj.hide = Hide.ToJsObject();
            }
            if (!Script.IsNaN(Show))
            {
                jObj.show = Show.ToJsObject();
            }
            return(jObj);
        }
Beispiel #3
0
 private int DrawContextGetHashCode(GeoCalcBound bound, List<GeoRasterStyle> styles, int transparency, HeightStyle heightStyle)
 {
     int num = (bound.GetHashCode() ^ transparency) ^ heightStyle.GetHashCode();
     foreach (GeoRasterStyle style in styles)
     {
         num ^= style.GetHashCode();
     }
     return num;
 }
Beispiel #4
0
 public GeoRasterLayer(IGeoRasterData geoRasterData, List<GeoRasterStyle> styles, IGeoRasterRender render)
 {
     this.m_Styles = new List<GeoRasterStyle>();
     this.m_Transparency = 0xff;
     this.m_HeightRenderStyle = HeightStyle.FullColor;
     this.m_RasterData = geoRasterData;
     this.m_Render = render;
     geoRasterData.OnDataChanged += new DataChangedEventHandler(this.RasieLayerChangedEvent);
     this.m_Styles.AddRange(styles);
     this.InitTransparency();
     base.GenerateLayerName(this.m_RasterData);
 }
Beispiel #5
0
 private unsafe void GrayBitmap(Bitmap bitmap, List<GeoRasterStyle> styles, HeightStyle heightStyle)
 {
     if (heightStyle == HeightStyle.Relief)
     {
         Rectangle rect = new Rectangle(0, 0, bitmap.Width, bitmap.Height);
         BitmapData bitmapdata = bitmap.LockBits(rect, ImageLockMode.ReadWrite, bitmap.PixelFormat);
         try
         {
             int stride = bitmapdata.Stride;
             int num2 = bitmap.Width * bitmap.Height;
             int num3 = (num2 - stride) - 1;
             int num4 = 0;
             byte* numPtr = (byte*) bitmapdata.Scan0.ToPointer();
             int num5 = 0;
             int count = styles.Count;
             while (num4 < num3)
             {
                 num4++;
                 if (numPtr[0] == 0)
                 {
                     numPtr++;
                 }
                 else
                 {
                     byte* numPtr2 = (numPtr + stride) + 1;
                     int num7 = numPtr2[0] - numPtr[0];
                     num5 = (count + num7) + 1;
                     numPtr++;
                     numPtr[0] = (byte) num5;
                 }
             }
         }
         catch (Exception)
         {
         }
         finally
         {
             bitmap.UnlockBits(bitmapdata);
         }
     }
 }
        internal object ToJsObject()
        {
            var obj = this.ToDynamic();

            if (Active == -2)
            {
                obj.active = false;
            }
            else if (Active == -1)
            {
                obj.active = true;
            }
            else
            {
                obj.active = Active;
            }

            if (Animate != null)
            {
                obj.animate = Animate.ToJsObject();
            }
            if (!Script.IsNaN(Classes))
            {
                obj.classes = Classes.ToJsDynamic();
            }

            if (!Script.IsNaN(Event))
            {
                obj["event"] = Event.ToString();
            }

            if (!Script.IsNaN(HeightStyle))
            {
                obj.heightStyle = HeightStyle.ToString();
            }

            return(obj);
        }
Beispiel #7
0
        private void SetPalette(Bitmap bitmap, List<GeoRasterStyle> styles, int transparency, HeightStyle heightStyle)
        {
            if (bitmap.Palette.Entries.Length > 0)
            {
                int num;
                List<Color> list = new List<Color>();
                switch (heightStyle)
                {
                    case HeightStyle.Normal:
                        num = 0;
                        while (num < styles.Count)
                        {
                            if (styles[num].Visible)
                            {
                                list.Add(Color.FromArgb(transparency, styles[num].Color));
                            }
                            else
                            {
                                list.Add(this.m_DefaultHeightColor);
                            }
                            num++;
                        }
                        break;

                    case HeightStyle.Relief:
                    {
                        int num2 = 100;
                        int num3 = 0xff / styles.Count;
                        int num4 = -styles.Count;
                        int count = styles.Count;
                        num = num4;
                        while (num <= count)
                        {
                            int num6 = (num * num3) + num2;
                            int red = Math.Abs(num6);
                            int green = Math.Abs(num6);
                            int blue = Math.Abs(num6);
                            if (red > 0xff)
                            {
                                red = 0xff;
                            }
                            if (green > 0xff)
                            {
                                green = 0xff;
                            }
                            if (blue > 0xff)
                            {
                                blue = 0xff;
                            }
                            list.Add(Color.FromArgb(transparency, red, green, blue));
                            num++;
                        }
                        break;
                    }
                    case HeightStyle.FullColor:
                    {
                        int num10 = 8;
                        int num11 = 0xff;
                        int num12 = num11 / styles.Count;
                        num = 0;
                        while (num < styles.Count)
                        {
                            GeoIntervalSytle sytle = styles[num] as GeoIntervalSytle;
                            Color color = sytle.Color;
                            int a = color.A;
                            int r = color.R;
                            int g = color.G;
                            int b = color.B;
                            for (int i = 0; i < num12; i++)
                            {
                                int num18 = r + (num10 * i);
                                int num19 = g + (num10 * i);
                                int num20 = b + (num10 * i);
                                if (num18 < 0)
                                {
                                    num18 = 0;
                                }
                                if (num18 > 0xff)
                                {
                                    num18 = 0xff;
                                }
                                if (num19 < 0)
                                {
                                    num19 = 0;
                                }
                                if (num19 > 0xff)
                                {
                                    num19 = 0xff;
                                }
                                if (num20 < 0)
                                {
                                    num20 = 0;
                                }
                                if (num20 > 0xff)
                                {
                                    num20 = 0xff;
                                }
                                Color item = Color.FromArgb(transparency, num18, num19, num20);
                                list.Add(item);
                            }
                            num++;
                        }
                        break;
                    }
                }
                ColorPalette palette = bitmap.Palette;
                palette.Entries[0] = this.m_DefaultHeightColor;
                for (num = 0; num < list.Count; num++)
                {
                    palette.Entries[num + 1] = list[num];
                }
                bitmap.Palette = palette;
            }
        }