Example #1
0
        private PixMap GetDummyXPixMap(BitmapColorMode bcm, bool b4Day, PixMap old)
        {
            if (old != null)
            {
                if (old.Colormode != bcm)
                {
                    switch (old.Colormode)
                    {
                    case BitmapColorMode.POLY1TR:
                        old.ChangeColorMode(BitmapColorMode.POLY2);
                        old.InvertBits();
                        old.SetNewColors(new Color[] { old.GetColor(0), Color.White });     // 2. Farbe einfach Weiß
                        break;

                    case BitmapColorMode.POLY2:
                        old.ChangeColorMode(BitmapColorMode.POLY1TR);
                        old.InvertBits();
                        old.SetNewColors(new Color[] { old.GetColor(0) });
                        break;
                    }
                }
                return(old);
            }

            PixMap pic = new PixMap(32, 32, 2, bcm);

            if (b4Day)
            {
                pic.SetNewColor(0, DayColor1);
                if (bcm == BitmapColorMode.POLY2)
                {
                    pic.SetNewColor(1, DayColor2);
                }
            }
            else
            {
                pic.SetNewColor(0, NightColor1);
                if (bcm == BitmapColorMode.POLY2)
                {
                    pic.SetNewColor(1, NightColor2);
                }
            }
            return(pic);
        }
Example #2
0
        /// <summary>
        /// setzt die Bitmaps (falls nicht null) mit dem einfachstmöglichen BitmapColorMode
        /// </summary>
        /// <param name="bmday"></param>
        /// <param name="bmnight"></param>
        /// <param name="bOnlyGarminColors">Die jeweils nächstgelegene Garminfarbe verwenden?</param>
        public void SetBitmaps(Bitmap bmday, Bitmap bmnight, bool bOnlyGarminColors)
        {
            if (bmday == null)
            {
                throw new Exception("Wenigstens das Tag-Bitmap muß gesetzt werden.");
            }
            if (bmnight != null)
            {
                if (bmday.Width != bmnight.Width || bmday.Height != bmnight.Height)
                {
                    throw new Exception("Beide Bitmaps müßen die gleiche Größe haben.");
                }
            }
            if ((bmday.Width > 255 || bmday.Height > 255) ||
                (bmnight != null && (bmnight.Width > 255 || bmnight.Height > 255)))
            {
                throw new Exception("Das Bitmap darf höchstens 255x255 groß sein.");
            }
            BitmapColorMode cm = GetMinBitmapColorMode(GetMinBitmapColorMode(bmday), GetMinBitmapColorMode(bmnight));

            ColormodeDay = cm;
            if (bmday != null)     // sonst bleibt das alte bestehen
            {
                XBitmapDay = new PixMap(bmday, ColormodeDay);
                if (bOnlyGarminColors)
                {
                    for (uint i = 0; i < XBitmapDay.Colors; i++)
                    {
                        XBitmapDay.SetNewColor(i, GraphicElement.GetNearestGarminColor(XBitmapDay.GetColor(i)));
                    }
                }
            }
            if (bmnight != null)
            {
                XBitmapNight = new PixMap(bmnight, ColormodeDay);
                WithNightXpm = true;
                if (bOnlyGarminColors)
                {
                    for (uint i = 0; i < XBitmapNight.Colors; i++)
                    {
                        XBitmapNight.SetNewColor(i, GraphicElement.GetNearestGarminColor(XBitmapNight.GetColor(i)));
                    }
                }
            }
            else
            {
                XBitmapNight = null;
                WithNightXpm = false;
            }
            Width  = XBitmapDay.Width;
            Height = XBitmapDay.Height;
        }
Example #3
0
        /// <summary>
        /// liefert das Bitmap (falls vorhanden)
        /// </summary>
        /// <param name="b4Day">für Tag oder Nacht</param>
        /// <param name="bExt">auch "bitmaplose" Linie als Bitmap 32 x n</param>
        /// <returns></returns>
        public override Bitmap AsBitmap(bool b4Day, bool bExt)
        {
            Bitmap bm = null;

            if (WithDayBitmap)
            {
                PixMap tmp = new PixMap(XBitmapDay);
                // Das Bitmap hat bisher nur eine Dummyfarbe. Jetzt müßen noch die richtigen Farben gesetzt werden.
                if (b4Day)
                {
                    switch (Polylinetype)
                    {
                    case PolylineType.Day2:
                    case PolylineType.Day2_Night2:
                    case PolylineType.NoBorder_Day2_Night1:
                        tmp.SetNewColors(colDayColor);
                        break;

                    case PolylineType.Day1_Night2:
                    case PolylineType.NoBorder_Day1:
                    case PolylineType.NoBorder_Day1_Night1:
                        tmp.SetNewColor(0, colDayColor[0]);
                        break;
                    }
                }
                else
                {
                    switch (Polylinetype)
                    {
                    case PolylineType.Day2:
                    case PolylineType.NoBorder_Day1:
                        tmp = null;
                        break;

                    case PolylineType.Day1_Night2:
                    case PolylineType.Day2_Night2:
                        tmp.SetNewColors(colNightColor);
                        break;

                    case PolylineType.NoBorder_Day2_Night1:
                    case PolylineType.NoBorder_Day1_Night1:
                        tmp.SetNewColor(0, colNightColor[0]);
                        break;
                    }
                }
                if (tmp != null)
                {
                    bm = tmp.AsBitmap();
                }
            }
            else
            {
                if (bExt)
                {
                    bm = new Bitmap(32, (int)(InnerWidth + 2 * BorderWidth));
                    for (int y = 0; y < bm.Height; y++)
                    {
                        bool  bBorder = y < BorderWidth || y >= (InnerWidth + BorderWidth);
                        Color col;
                        if (b4Day)
                        {
                            col = bBorder ? colDayColor[1] : colDayColor[0];
                        }
                        else
                        {
                            col = bBorder ? colNightColor[1] : colNightColor[0];
                        }
                        for (int x = 0; x < bm.Width; x++)
                        {
                            bm.SetPixel(x, y, col);
                        }
                    }
                }
            }
            return(bm);
        }