示例#1
0
        public void ApplyFilters(List <Schema.SkinFile.Attachment.Filter> filters)
        {
            if (dib.IsNull)
            {
                return;
            }

            foreach (Schema.SkinFile.Attachment.Filter filter in filters)
            {
                switch (filter.name)
                {
                case "invert":
                {
                    ///
                    /// TODO: Variable invertion using amount property
                    ///
                    FreeImage.AdjustColors(dib, 0, 0, 0, true);
                    break;
                }

                case "colorOverlay":
                {
                    try
                    {
                        ///
                        /// TODO: Variable overlay using amount property
                        ///
                        RGBQUAD overlayColor = new RGBQUAD(), oldColor;
                        overlayColor.uintValue = Convert.ToUInt32(filter.color, 16);
                        //Console.WriteLine((double)filter.amount / 100);
                        for (uint y = 0; y < FreeImage.GetHeight(dib); y++)
                        {
                            for (uint x = 0; x < FreeImage.GetWidth(dib); x++)
                            {
                                FreeImage.GetPixelColor(dib, x, y, out oldColor);
                                overlayColor.rgbReserved = oldColor.rgbReserved;
                                FreeImage.SetPixelColor(dib, x, y, ref overlayColor);
                            }
                        }
                    }
                    catch { }
                    break;
                }
                }
            }
        }