Exemple #1
0
        internal void ReCreateBitmap(µImage image, PaletteType paletteType, ref WriteableBitmap writeableBitmap)
        {
            PixelFormat   pixelFormat;
            BitmapPalette palette;

            switch (paletteType)
            {
            case PaletteType.Default:
                palette     = null;
                pixelFormat = PixelFormats.Gray8;
                break;

            default:
                palette     = µPalette.GetPalette(paletteType);
                pixelFormat = PixelFormats.Indexed8;
                break;
            }

            if ((null == writeableBitmap) ||
                (image.Width != writeableBitmap.Width) || (image.Height != writeableBitmap.Height) ||
                (paletteType != _previousPaletteType) || (pixelFormat != _previousPixelFormat))
            {
                writeableBitmap = new WriteableBitmap(image.Width, image.Height, 96, 96, pixelFormat, palette);
            }
            ToWriteableBitmap(image, writeableBitmap, displayMapping);
            this.ApplyWriteableBitmap(writeableBitmap);
            this.ApplyµImage(image);
            _previousPaletteType = paletteType;
            _previousPixelFormat = pixelFormat;
        }
 public static void ChangeTo4bppIndexed(this Bitmap Bmp, PaletteType palettetype = PaletteType.PaletteTypeOptimal,
     DitherType ditherType = DitherType.DitherTypeErrorDiffusion, int optimalColors = 16)
 {
     int Entries;
     // http://msdn.microsoft.com/en-us/library/ms534159(v=vs.85).aspx
     switch (palettetype)
     {
         case PaletteType.PaletteTypeFixedBW:
             Entries = 2;
             break;
         case PaletteType.PaletteTypeFixedHalftone8:
             Entries = 16;
             break;
         case PaletteType.PaletteTypeOptimal:
             if (optimalColors <= 0 || optimalColors > 16)
                 throw new ArgumentOutOfRangeException("Colors should be between 0 (inclusive) and 16 (exclusive)");
             Entries = optimalColors;
             break;
         default:
             throw new ArgumentException("Error");
     }
     var Pal = new int[2 + Entries];
     Pal[0] = (int) PaletteFlags.GrayScale; // Flag
     Pal[1] = Entries; // Count
     if (palettetype == PaletteType.PaletteTypeOptimal)
         GdipInitializePalette(Pal, palettetype, Entries, 0, Bmp.NativeHandle());
     else
         GdipInitializePalette(Pal, palettetype, Entries, 0, IntPtr.Zero);
     if (palettetype == PaletteType.PaletteTypeOptimal)
         if (ditherType != DitherType.DitherTypeNone && ditherType != DitherType.DitherTypeSolid &&
             ditherType != DitherType.DitherTypeErrorDiffusion)
             throw new ArgumentException("Arguments error");
     GdipBitmapConvertFormat(Bmp.NativeHandle(), Convert.ToInt32(PixelFormat.Format4bppIndexed), ditherType,
         palettetype, Pal, 50f);
 }
Exemple #3
0
        public void SetActiveContentView(PaletteType paletteType)
        {
            switch (paletteType)
            {
            case PaletteType.Color:
                _activeWindowContentsView = _colorContentsView;
                break;

            case PaletteType.Gradient:
                _activeWindowContentsView = _gradientContentsView;
                break;

            case PaletteType.CharacterStyle:
                _activeWindowContentsView = _characterStyleContentsView;
                break;

            case PaletteType.CharacterStyleTMP:
                _activeWindowContentsView = _characterStyleTMPContentsView;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(paletteType), paletteType, null);
            }

            _activePaletteType = paletteType;

            Repaint();
        }
        public override Helix.Element3D GetElement(SceneNodeModel treeNode, int itemIndex)
        {
            var nodeType   = treeNode?.NodeType ?? NodeType.None;
            var paletteKey = PaletteType.FromNodeType(nodeType);

            return(PaletteHolders[paletteKey].Elements[itemIndex]);
        }
Exemple #5
0
        public async Task SmearAsync(PaletteType a, PaletteType b)
        {
            GammaPalette result = GammaPalette.Smear(GraphicsService.GetPalette(a), GraphicsService.GetPalette(b));

            await Context.Channel.SendImageAsync(ImageHelper.CreateGradient(result, 128, 64, AngleF.Right),
                                                 "../tmp/smear.png");
        }
Exemple #6
0
        private static Texture2D CreateTexture(PaletteType paletteType)
        {
            Texture2D texture = CreateTexture(GetPalette(paletteType));

            Textures[paletteType] = texture;
            return(texture);
        }
Exemple #7
0
 public ChatHandler(DesyncContext context, Character npc, DialogTree pool, PaletteType palette = PaletteType.Glass)
 {
     Context = context;
     Npc     = npc;
     Tree    = pool;
     Palette = GraphicsService.GetPalette(palette);
 }
 public PaletteRenderer(PalettesService paletteService, PaletteType paletteType) : base(null)
 {
     _buffer          = new byte[256 * (paletteType == PaletteType.Full ? 64 : 32) * BYTES_PER_BLOCK];
     _paletteType     = paletteType;
     _palettesService = paletteService;
     BYTE_STRIDE      = 256 * 4;
 }
Exemple #9
0
        public ColorPicker(
            Color pickerColor,
            ValueChanged <Color> onColorChanged,
            TextStyle labelTextStyle            = null,
            PaletteType paletteType             = PaletteType.hsv,
            BorderRadius pickerAreaBorderRadius = null,
            bool enableAlpha              = true,
            bool displayThumbColor        = false,
            bool portraitOnly             = false,
            bool showLabel                = true,
            float colorPickerWidth        = 300f,
            float pickerAreaHeightPercent = 1f
            )
        {
            this.pickerColor    = pickerColor;
            this.onColorChanged = onColorChanged;
            this.labelTextStyle = labelTextStyle;
            this.paletteType    = paletteType;

            if (pickerAreaBorderRadius == null)
            {
                this.pickerAreaBorderRadius = BorderRadius.all(Radius.zero);
            }
            else
            {
                this.pickerAreaBorderRadius = pickerAreaBorderRadius;
            }

            this.enableAlpha             = enableAlpha;
            this.displayThumbColor       = displayThumbColor;
            this.portraitOnly            = portraitOnly;
            this.showLabel               = showLabel;
            this.colorPickerWidth        = colorPickerWidth;
            this.pickerAreaHeightPercent = pickerAreaHeightPercent;
        }
Exemple #10
0
    private static void ChangeSprtRendererColor(SpriteRenderer spriteRnd, PaletteType palette, Saturation saturation, float alpha = 1)
    {
        if (palette == PaletteType.Main && saturation >= Saturation.Accent100)
        {
            Debug.LogError("The palette type Main doesn't match with Accent Saturation");
        }
        if (palette == PaletteType.Accent && saturation < Saturation.Accent100)
        {
            Debug.LogError("The palette type Accent doesn't match with Main Saturation");
        }

        Color newColor;

        if (palette == PaletteType.Main)
        {
            // spriteRnd.color = mainPalette[(int)saturation];
            newColor = PlayerInfo.info.GetMainColor(saturation);
        }
        else
        {
            // spriteRnd.color = accentPalette[(int)saturation];
            newColor = PlayerInfo.info.GetAcColorBySaturation(saturation);
        }

        newColor.a      = alpha;
        spriteRnd.color = newColor;
    }
        /// <summary>
        /// Gets the palette's base format.
        /// </summary>
        /// <param name="palette">Palette</param>
        /// <returns>Base format</returns>
        public static DataFormat GetPaletteBaseFormat(PaletteType palette)
        {
            switch (palette)
            {
            case PaletteType.RGB24:
                return(DataFormat.RGB);

            case PaletteType.RGB32:
                return(DataFormat.RGBA);    //DevIL says its not sure

            case PaletteType.RGBA32:
                return(DataFormat.RGBA);

            case PaletteType.BGR24:
                return(DataFormat.BGR);

            case PaletteType.BGR32:
                return(DataFormat.BGRA);    //DevIL says its not sure

            case PaletteType.BGRA32:
                return(DataFormat.BGRA);

            default:
                return(DataFormat.RGBA);
            }
        }
Exemple #12
0
 public ShopHandler(DesyncContext context, Market market, PaletteType palette)
 {
     Context = context;
     Market  = market;
     Vendor  = market.GetActive();
     Palette = GraphicsService.GetPalette(palette);
 }
        public override bool ExecuteObjectOperation(SceneNodeModel treeNode, ObjectOperation operation, int itemIndex)
        {
            var paletteKey = PaletteType.FromNodeType(treeNode.NodeType);
            var holder     = PaletteHolders[paletteKey];

            var blockEditor = scenario.MetadataStream.GetBlockEditor(holder.Definition.PlacementBlockRef.TagBlock.Pointer.Address);

            switch (operation)
            {
            case ObjectOperation.Add:
                blockEditor.Add();
                blockEditor.UpdateBlockReference(holder.Definition.PlacementBlockRef);

                var placement = holder.InsertPlacement(blockEditor.EntryCount - 1, scenario, paletteKey);

                //setting the palette index causes a refresh which builds an element for the new object
                //these also need to be set to -1 initially anyway
                placement.PaletteIndex = placement.NameIndex = -1;
                break;

            case ObjectOperation.Remove:
                if (itemIndex < 0 || itemIndex >= holder.Definition.Placements.Count)
                {
                    return(false);
                }

                ShiftObjectNames(paletteKey, itemIndex, holder.Definition.Placements.Count, true);

                blockEditor.Remove(itemIndex);
                blockEditor.UpdateBlockReference(holder.Definition.PlacementBlockRef);
                holder.RemovePlacement(itemIndex);

                UpdateBlockIndexes(paletteKey, itemIndex, holder.Definition.Placements.Count);
                break;

            case ObjectOperation.Copy:
                if (itemIndex < 0 || itemIndex >= holder.Definition.Placements.Count)
                {
                    return(false);
                }

                ShiftObjectNames(paletteKey, itemIndex, holder.Definition.Placements.Count, false);

                var destIndex = itemIndex + 1;
                blockEditor.Copy(itemIndex, destIndex);
                blockEditor.UpdateBlockReference(holder.Definition.PlacementBlockRef);

                placement = holder.InsertPlacement(destIndex, scenario, paletteKey);
                placement.CopyFrom(holder.Definition.Placements[itemIndex]);

                UpdateBlockIndexes(paletteKey, itemIndex, holder.Definition.Placements.Count);
                break;

            default:
                return(false);
            }

            return(true);
        }
Exemple #14
0
 public SetPaletteColor(EditroidUndoRedoQueue q, Level level, PaletteType type, int palette, int index, int newValue)
     : base(q, level)
 {
     this.type       = type;
     this.entryIndex = palette * 4 + index;
     this.newValue   = (byte)(newValue & 0xFF);
     this.oldValue   = Palette.GetEntry(entryIndex);
 }
Exemple #15
0
 public Color[][] GetPalettes(PaletteType type)
 {
     if (palettesModified)
     {
         RegeneratePalettes();
     }
     return(paletteBuffer[(int)type]);
 }
        private void OnActivePaletteTypeChanged(PaletteType type)
        {
            var oldType = _guiState.ActivePaletteType.Value;

            _editService.Edit($"Change Palette Type To {type.ToString()}",
                              () => _guiState.ActivePaletteType.Value = type,
                              () => _guiState.ActivePaletteType.Value = oldType, false);
        }
        public DImage()
        {
            this.size = Size.Empty;

            this.channel_type = ChannelType.Invalid;
            this.type         = ImageType.Invalid;
            this.palette_type = PaletteType.Invalid;
        }
Exemple #18
0
        public Palette(string fullFileName)
        {
            this.name = Path.GetFileName(fullFileName);
            Bitmap bmp = (Bitmap)Image.FromFile(fullFileName);

            this.type = PaletteType.FromFile;
            fillFromBitmap(bmp);
        }
        public override IEnumerable <ScenarioListItem> GetListItems(SceneNodeModel treeNode)
        {
            var paletteKey = PaletteType.FromNodeType(treeNode.NodeType);

            foreach (var placement in scenario.Palettes[paletteKey].Placements)
            {
                yield return(new ScenarioListItem(placement));
            }
        }
Exemple #20
0
    private void SetPalette(PaletteType t)
    {
        // select palette
        Palette palette = default;

        switch (t)
        {
        case PaletteType.NoColor:
            palette = NoColor;
            break;

        case PaletteType.BlockHues:
        case PaletteType.Color:
            palette = ColoredBlocks;
            break;
        }

        // balls
        for (int i = 0; i < Balls.Count; i++)
        {
            Balls[i].SpriteRenderer.color = palette.Ball;
        }

        // blocks
        Color blockColor = palette.Blocks;

        for (int i = 0; i < Blocks.Count; i++)
        {
            if (t == PaletteType.BlockHues && i % BlockColumns == 0)             // color blocks by row
            {
                // shift hue a bit
                float h = 0f;
                float s = 0f;
                float v = 0f;
                Color.RGBToHSV(blockColor, out h, out s, out v);
                h          = (h + 0.05f) % 1f;
                blockColor = Color.HSVToRGB(h, s, v);
            }

            Blocks[i].SpriteRenderer.color = blockColor;
        }

        // walls
        for (int i = 0; i < Walls.Length; i++)
        {
            Transform wall = Walls[i].transform;
            wall.GetComponentInChildren <SpriteRenderer>().color = palette.Walls;
        }

        // paddle
        Paddle.SpriteRenderer.color = palette.Paddle;

        // background
        MainCamera.backgroundColor = palette.Background;

        currentPalette = t;
    }
        public static Material LoadMaterial(string _materialID, PaletteType _type = PaletteType.diffuse_saturated)
        {
            Material m = Resources.Load <Material>(string.Format("{0}{1}", string.Format("{0}{1}/", MATERIALS_REOURCES_PATH, _type.ToString()), _materialID));

            if (m == null)
            {
                m = Resources.Load <Material>(string.Format("{0}{1}_{2}", MATERIALS_REOURCES_PATH, "white", "pure"));
                //Debug.LogFormat("Material not found {0}_{1} in path {2}", _color, _tone, MATERIALS_REOURCES_PATH);
            }
            return(m);
        }
        private void btnEditPalette_Click(object sender, RoutedEventArgs e)
        {
            var paletteKey = PaletteType.FromNodeType(scenario.SelectedNodeType);

            if (paletteKey != null)
            {
                new PaletteEditorWindow(scenario, paletteKey)
                {
                    Owner = Window.GetWindow(this)
                }
            }
 private void setup()
 {
     mPalette       = (IntPtr)null;
     mPalSize       = 0;
     mPalType       = PaletteType.None;
     mNumCols       = 0;
     mNumComponents = 0;
     mRedOffset     = 0;
     mGreenOffset   = 0;
     mBlueOffset    = 0;
     mAlphaOffset   = 0;
 }
        private void AddPaletteTool(PaletteType paletteType, string imageName)
        {
            var toolStripButton = new ToolStripButton
            {
                DisplayStyle = ToolStripItemDisplayStyle.Image,
                Image        = imageList.Images[imageName],
                Size         = toolSize,
            };

            toolStripButton.Click += (s, e) => PaletteToolClicked?.Invoke(s, new PaletteToolClickedEventArgs(paletteType));
            Items.Add(toolStripButton);
        }
Exemple #25
0
        public SpritePalette(PaletteType Type)
        {
            if (Type == PaletteType.Color16)
            {
                this.Colors = new GBAcolor[16];
            }

            else
            {
                this.Colors = new GBAcolor[256];
            }
            this.Type = Type;
        }
Exemple #26
0
        public SpritePalette(PaletteType Type)
        {
            if (Type == PaletteType.Color16)
            {
                this.Colors = new Palette[16];
            }

            if (Type == PaletteType.Color256)
            {
                this.Colors = new Palette[256];
            }
            this.Type = Type;
        }
Exemple #27
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var nodeType = value as NodeType? ?? NodeType.None;
            var action   = parameter?.ToString();

            var paletteKey = PaletteType.FromNodeType(nodeType);

            if (paletteKey != null)
            {
                return(true);
            }

            return(false);
        }
        public override void OnSelectedTreeNodeChanged(SceneNodeModel newNode)
        {
            var nodeType = newNode?.NodeType ?? NodeType.None;

            //if the node is not a palette this will disable hit testing on all palettes
            var paletteKey = PaletteType.FromNodeType(nodeType);

            foreach (var palette in PaletteHolders.Values)
            {
                palette.GroupElement.IsHitTestVisible = palette.Name == paletteKey;
            }

            //only render decals when the decal node is selected
            PaletteHolders[PaletteType.Decal].GroupElement.IsRendering = nodeType == NodeType.Decals;
        }
Exemple #29
0
        public async Task GetCardAsync(bool trim, CardDeny deny, BorderAllow border,
                                       Casing casing, FontType font, PaletteType palette, Gamma usernameGamma = Gamma.Max,
                                       Gamma activityGamma = Gamma.Max, Gamma borderGamma = Gamma.Max, ImageScale scale = ImageScale.Medium, int padding = 2)
        {
            SocketUser user = Context.User;

            if (!Context.Container.TryGetUser(user.Id, out User account))
            {
                await Context.Channel.ThrowAsync("The specified user does not have an existing account.");

                return;
            }

            try
            {
                using var graphics = new GraphicsService();
                var d = new CardDetails(account, user);

                var p = new CardProperties
                {
                    Trim    = trim,
                    Deny    = deny,
                    Border  = border,
                    Casing  = casing,
                    Font    = font,
                    Palette = palette,
                    Gamma   = new Dictionary <CardComponentType, Gamma?>
                    {
                        [CardComponentType.Username]   = usernameGamma,
                        [CardComponentType.Activity]   = activityGamma,
                        [CardComponentType.Border]     = borderGamma,
                        [CardComponentType.Background] = null,
                        [CardComponentType.Avatar]     = Gamma.Max
                    },
                    Padding = new Padding(padding),
                    Scale   = scale
                };

                Bitmap card = graphics.DrawCard(d, p);

                Logger.Debug("Drawing card...");
                await Context.Channel.SendImageAsync(card, $"../tmp/{Context.User.Id}_card.png");
            }
            catch (Exception ex)
            {
                await Context.Channel.CatchAsync(ex);
            }
        }
        public static UInt32[] GetPalette(PaletteType pt)
        {
            if (pt == PaletteType.Gray)
            {
                return(Gray());
            }
            if (pt == PaletteType.Iron)
            {
                return(Iron());
            }
            if (pt == PaletteType.Rain)
            {
                return(Rain());
            }

            throw new Exception("Invalid PaletteType constant");
        }
 public static Color[] GetColorPalette(Color mainColor, PaletteType type)
 {
     switch (type)
     {
         case PaletteType.Monochromatic:
             return GetColorPaletteMonochromatic(mainColor);
         case PaletteType.Analogous:
             return GetColorPaletteAnalogous(mainColor,30f,4);
         case PaletteType.Triadic:
             return GetColorPaletteAngleDiff(mainColor, 120f);
         case PaletteType.SplitComplement:
             return GetColorPaletteAngleDiff(mainColor, 150f);
         case PaletteType.Complement:
             return GetColorPaletteComplement(mainColor);
     }
     return null;
 }
Exemple #32
0
 public static bool ConvertPalette(PaletteType palType) {
     return ilConvertPal((uint) palType);
 }
Exemple #33
0
 public static extern int imaqSetWindowPalette(int windowNumber, PaletteType type, ref RGBValue palette, int numColors);
Exemple #34
0
 public Color[][] GetPalettes(PaletteType type)
 {
     if (palettesModified)
         RegeneratePalettes();
     return paletteBuffer[(int)type];
 }
        void OnGUI()
        {
            bool lastShowSceneColors = showSceneColors;
            SetStyles();

            scrollPos = EditorGUILayout.BeginScrollView(scrollPos);

            #region UI Colors
            GUILayout.Label("UI Colors", titleStyle);
            normal = EditorGUILayout.ColorField("Normal", normal);
            highlighted = EditorGUILayout.ColorField("Highlighted", highlighted);
            pressed = EditorGUILayout.ColorField("Pressed", pressed);
            disabled = EditorGUILayout.ColorField("Disabled", disabled);
            detail = EditorGUILayout.ColorField("Detail", detail);

            if (GUILayout.Button("Apply Colors to Selected UI"))
            {
                AssignColorsToSelection();
            }

            GUILayout.BeginHorizontal();
            showColors = GUILayout.Toggle(showColors, "Suggestions", "Button");
            showSuggestions = GUILayout.Toggle(showSuggestions, "Schemes", "Button");
            showSceneColors = GUILayout.Toggle(showSceneColors, "Scene Colors", "Button");
            // If the toggle was activated, refresh and search for the new colors in scene
            if (showSceneColors != lastShowSceneColors && showSceneColors)
            {
                SearchSceneColors();
            }
            GUILayout.EndHorizontal();

            Color defaultBg = GUI.backgroundColor;
            if (showSceneColors)
            {
                GUILayout.Label("Scene Colors", EditorStyles.boldLabel);
                GUI.backgroundColor = Color.black;
                GUILayout.BeginVertical(bgStyle);
                GUILayout.BeginHorizontal();
                int counter = 0;
                foreach (Color color in sceneColors)
                {
                    GUI.backgroundColor = color; // Sets the button color
                    if (GUILayout.Button("", btnStyle))
                    {
                        SetColors(GetColorDefault(color));
                        selectedColor = color;
                    }
                    counter++;
                    if (counter % 5 == 0)
                    {
                        // Start a new row each 5
                        GUILayout.EndHorizontal();
                        GUI.backgroundColor = Color.black;
                        GUILayout.BeginHorizontal();
                    }
                }
                GUILayout.EndHorizontal();
                GUI.backgroundColor = defaultBg; // Resets the color background

                GUILayout.EndVertical();
            }

            if (showSuggestions)
            {
                GUILayout.Label("Color Scheme Generator", EditorStyles.boldLabel);
                paletteType = (PaletteType)EditorGUILayout.EnumPopup("Scheme: ", paletteType);
                selectedColor = EditorGUILayout.ColorField("Base:", selectedColor);

                GUI.backgroundColor = Color.black;
                GUILayout.BeginVertical(bgStyle);
                GUI.backgroundColor = selectedColor; // Sets the button color
                if (GUILayout.Button("", btnStyle))
                {
                    SetColors(GetColorDefault(selectedColor));
                }
                Color[] paletteColors = GamestrapHelper.GetColorPalette(selectedColor, paletteType);
                GUILayout.BeginHorizontal();
                for (int i = 0; i < paletteColors.Length; i++)
                {
                    GUI.backgroundColor = paletteColors[i]; // Sets the button color
                    if (GUILayout.Button("", btnStyle))
                    {
                        SetColors(GetColorDefault(paletteColors[i]));
                    }
                }
                GUI.backgroundColor = defaultBg; // Resets the color background
                GUILayout.EndHorizontal();
                GUILayout.EndVertical();
            }

            if (showColors)
            {
                GUILayout.Label("Color Suggestions", EditorStyles.boldLabel);
                GUI.backgroundColor = Color.black;
                GUILayout.BeginVertical(bgStyle);
                GUILayout.BeginHorizontal();
                int counter = 0;
                foreach (Color[] color in colors)
                {
                    GUI.backgroundColor = color[0]; // Sets the button color
                    if (GUILayout.Button("", btnStyle) && color.Length >= 5)
                    {
                        SetColors(color);
                        selectedColor = color[0];
                    }
                    counter++;
                    if (counter % 5 == 0)
                    {
                        // Start a new row each 5
                        GUILayout.EndHorizontal();
                        GUI.backgroundColor = Color.black;
                        GUILayout.BeginHorizontal();
                    }
                }
                GUILayout.EndHorizontal();
                GUI.backgroundColor = defaultBg; // Resets the color background

                GUILayout.EndVertical();
            }

            #endregion

            #region Font
            GUILayout.Label("Font", titleStyle);
            GUILayout.BeginHorizontal();
            font = (Font)EditorGUILayout.ObjectField(font, typeof(Font), false);
            if (GUILayout.Button("Apply"))
            {
                AssignFontToSelection();
            }
            GUILayout.EndHorizontal();
            #endregion

            #region Effects
            GUILayout.Label("Effects", titleStyle);
            shadow = EditorGUILayout.ToggleLeft("Shadow", shadow);
            if (shadow)
            {
                shadowColor = EditorGUILayout.ColorField("Color", shadowColor);
                shadowDistance = EditorGUILayout.Vector2Field("Effect Distance", shadowDistance);
            }
            gradient = EditorGUILayout.ToggleLeft("Gradient", gradient);
            if (gradient)
            {
                gradientTop = EditorGUILayout.ColorField("Color Top", gradientTop);
                gradientBottom = EditorGUILayout.ColorField("Color Bottom", gradientBottom);
            }

            if (GUILayout.Button("Activate/Deactivate"))
            {
                ActivateEffects();
            }
            #endregion

            EditorGUILayout.EndScrollView();
        }
 private void setup()
 {
     mPalette = (IntPtr)null;
     mPalSize = 0;
     mPalType = PaletteType.None;
     mNumCols = 0;
     mNumComponents = 0;
     mRedOffset = 0;
     mGreenOffset = 0;
     mBlueOffset = 0;
     mAlphaOffset = 0;
 }
        bool use(uint aNumCols, IntPtr aPal, PaletteType aPalType)
        {
            if (mPalette != null)
                mPalette = (IntPtr)null;

            switch(aPalType)
            {
            case PaletteType.RGB24:
                mNumComponents = 3;
                mRedOffset = 0;
                mGreenOffset = 1;
                mBlueOffset = 2;
                mAlphaOffset = -1;
                break;
            case PaletteType.RGB32:
                mNumComponents = 4;
                mRedOffset = 0;
                mGreenOffset = 1;
                mBlueOffset = 2;
                mAlphaOffset = -1;
                break;
            case PaletteType.RGBA32:
                mNumComponents = 4;
                mRedOffset = 0;
                mGreenOffset = 1;
                mBlueOffset = 2;
                mAlphaOffset = 3;
                break;
            case PaletteType.BGR24:
                mNumComponents = 3;
                mRedOffset = 2;
                mGreenOffset = 1;
                mBlueOffset = 0;
                mAlphaOffset = -1;
                break;
            case PaletteType.BGR32:
                mNumComponents = 4;
                mRedOffset = 2;
                mGreenOffset = 1;
                mBlueOffset = 0;
                mAlphaOffset = -1;
                break;
            case PaletteType.BGRA32:
                mNumComponents = 4;
                mRedOffset = 3;
                mGreenOffset = 2;
                mBlueOffset = 1;
                mAlphaOffset = 0;
                break;
            case PaletteType.None:
            default:
                mNumComponents = 0;
                mRedOffset = 0;
                mGreenOffset = 0;
                mBlueOffset = 0;
                mAlphaOffset = 0;
                break;
            }

            if (mNumComponents > 0 && aNumCols > 0)
            {
            mNumCols = aNumCols;
            mPalSize = (uint)(aNumCols * mNumComponents);
            if (mPalette != null)
            {
                if (aPal != null)
                    mPalette = aPal;
                mPalType = aPalType;
                return true;
            }
            else
                return false;
            }
            else
            return true;
        }