public void MakeColorTransparent(byte red0, byte green0, byte blue0, byte red1, byte green1, byte blue1)
        {
            DatImageFormat format = this.Format;

            var data = this.GetImageData();

            if (data == null)
            {
                return;
            }

            int length = data.Length / 4;

            for (int i = 0; i < length; i++)
            {
                byte r = data[i * 4 + 2];
                byte g = data[i * 4 + 1];
                byte b = data[i * 4 + 0];

                if (r >= red0 && r <= red1 && g >= green0 && g <= green1 && b >= blue0 && b <= blue1)
                {
                    data[i * 4 + 3] = 0;
                }
            }

            this.Format      = DatImageFormat.Format25;
            this.ColorsCount = 0;
            this.rawData     = data;

            this.ConvertToFormat(format);
        }
        public void MakeColorTransparent(byte red, byte green, byte blue)
        {
            DatImageFormat format = this.Format;

            var data = this.GetImageData();

            if (data == null)
            {
                return;
            }

            int length = data.Length / 4;

            for (int i = 0; i < length; i++)
            {
                byte r = data[i * 4 + 2];
                byte g = data[i * 4 + 1];
                byte b = data[i * 4 + 0];

                if (r == red && g == green && b == blue)
                {
                    data[i * 4 + 3] = 0;
                }
            }

            this.Format      = DatImageFormat.Format25;
            this.ColorsCount = 0;
            this.rawData     = data;

            this.ConvertToFormat(format);
        }
        public static DatImage FromMemory(short groupId, short imageId, DatImageFormat format, short width, short height, short colorsCount, byte[] rawData)
        {
            DatImage image = new DatImage(groupId, imageId);

            image.ReplaceWithMemory(format, width, height, colorsCount, rawData);

            return(image);
        }
 public void ReplaceWithMemory(DatImageFormat format, short width, short height, short colorsCount, byte[] data)
 {
     this.Format      = format;
     this.Width       = width;
     this.Height      = height;
     this.ColorsCount = colorsCount;
     this.rawData     = data;
 }
        public void ConvertToType(DatImageFormat format)
        {
            switch (format)
            {
            case DatImageFormat.Format25:
                this.ConvertToFormat25();
                break;

            case DatImageFormat.Format24:
                this.ConvertToFormat24();
                break;

            case DatImageFormat.Format7:
                this.ConvertToFormat7();
                break;

            case DatImageFormat.Format23:
                this.ConvertToFormat23();
                break;

            default:
                throw new ArgumentOutOfRangeException("format");
            }
        }
        public void ConvertToType(DatImageFormat format)
        {
            switch (format)
            {
                case DatImageFormat.Format25:
                    this.ConvertToFormat25();
                    break;

                case DatImageFormat.Format24:
                    this.ConvertToFormat24();
                    break;

                case DatImageFormat.Format7:
                    this.ConvertToFormat7();
                    break;

                case DatImageFormat.Format23:
                    this.ConvertToFormat23();
                    break;

                default:
                    throw new ArgumentOutOfRangeException("format");
            }
        }
        public static DatImage FromMemory(short groupId, short imageId, DatImageFormat format, short width, short height, short colorsCount, byte[] rawData)
        {
            DatImage image = new DatImage(groupId, imageId);

            image.ReplaceWithMemory(format, width, height, colorsCount, rawData);

            return image;
        }
 public void ReplaceWithMemory(DatImageFormat format, short width, short height, short colorsCount, byte[] data)
 {
     this.Format = format;
     this.Width = width;
     this.Height = height;
     this.ColorsCount = colorsCount;
     this.rawData = data;
 }