Esempio n. 1
0
        private IEnumerable <Color> GeneratePalette()
        {
            if (Bitmap == null)
            {
                return(Enumerable.Empty <Color>());
            }
            byte[] bgrData = null;
            switch (Width)
            {
            case 512:
            {
                var crop = new CroppedBitmap(Bitmap, new Int32Rect(0, 0, 412, 240));
                bgrData = crop.GetBgr24Data();
                break;
            }

            case 1024:
            {
                // It Has a 920 Version, but the Max data is 1008, bear with a little gray
                var crop = new CroppedBitmap(Bitmap, new Int32Rect(0, 0, 1008, 240));
                bgrData = crop.GetBgr24Data();
                break;
            }

            default:
            {
                bgrData = Bitmap.GetBgr24Data();
                break;
            }
            }

            return(GraphicUtils.PaletteGen(bgrData, 20).Select(Extensions.ToMediaColor).ToList());
        }