Exemplo n.º 1
0
        internal TIM2Segment(Image image, IList <Color[]> palettes, TIM2SegmentParameters parameters)
        {
            this.parameters = parameters;
            swizzleFilter   = new SwizzleFilter(parameters.width, parameters.height, parameters.bpp);
            paletteFilter   = new TIM2PaletteFilter(parameters.bpp);

            if (parameters.bpp > 8)                                                                  //true color image
            {
                imageData = GetColorCodec(parameters.colorSize).EncodeColors(image.GetColorArray()); //I love extension methods. Hurray!
            }
            else
            {
                ImageEncoderIndexed encoder;
                if (palettes != null)
                {
                    encoder = new ImageEncoderIndexed(palettes, image, IndexCodec.FromBitPerPixel(parameters.bpp));
                }
                else
                {
                    encoder = new ImageEncoderIndexed(image, IndexCodec.FromBitPerPixel(parameters.bpp), new ARGBColorComparer());
                }

                imageData     = encoder.Encode();
                this.palettes = new List <Color[]>(encoder.Palettes).ToArray();
            }
            CreateImageDecoder(imageData);
        }
Exemplo n.º 2
0
        private void Init(Image referenceImage, IList <Color[]> palettes)
        {
            width  = referenceImage.Width;
            height = referenceImage.Height;

            ImageEncoderIndexed encoder = new ImageEncoderIndexed(palettes,
                                                                  referenceImage,
                                                                  IndexCodec,
                                                                  PaletteCodec,
                                                                  ImageFilter,
                                                                  PaletteFilter);

            imageData     = encoder.Encode();
            this.palettes = encoder.Palettes;

            encodedPalettes = encoder.EncodedPalettes;
        }
Exemplo n.º 3
0
        private void Init(Image image)
        {
            width  = image.Width;
            height = image.Height;

            ImageEncoderIndexed encoder = new ImageEncoderIndexed(image,
                                                                  IndexCodec,
                                                                  PixelComparer,
                                                                  PaletteCodec,
                                                                  ImageFilter,
                                                                  PaletteFilter);

            imageData = encoder.Encode();
            palettes  = encoder.Palettes;

            encodedPalettes = encoder.EncodedPalettes;
        }
Exemplo n.º 4
0
        internal PE3SimpleDATTexture(byte[] rawHeader, Image img)
        {
            this.rawHeader = rawHeader;
            if (img.Width != 512)
            {
                throw new TextureFormatException("Only a width of 512 pixel is allowed!");
            }

            width  = img.Width;
            height = img.Height;

            ImageEncoderIndexed encoder = new ImageEncoderIndexed(img,
                                                                  IndexCodec.FromBitPerPixel(4), null, null,
                                                                  new SwizzleFilter(width, height, 4));

            imageData = encoder.Encode();
        }
Exemplo n.º 5
0
        internal PE3DATTexture(IList <Image> images, uint[] pos1, uint[] pos2, ushort[] w, ushort[] h, int[] bpps)
        {
            imagesData = new List <byte[]>(images.Count);
            palettes   = new List <Color[]>(images.Count);
            positions1 = pos1;
            positions2 = pos2;
            widths     = w;
            heights    = h;
            this.bpps  = bpps;

            for (int i = 0; i < images.Count; i++)
            {
                if (bpps[i] != 8 && bpps[i] != 4)
                {
                    throw new TextureFormatException("Illegal bpp value: " + bpps[i]);
                }

                Image img = images[i];
                ImageEncoderIndexed encoder = new ImageEncoderIndexed(img, IndexCodec.FromBitPerPixel(bpps[i]), null, null, new SwizzleFilter(widths[i], heights[i], bpps[i]));
                imagesData.Add(encoder.Encode());
                palettes.Add(encoder.Palettes[0]);
            }
        }