示例#1
0
        public PalettedImage8bpp(
            string name,
            int width, int height,
            int numPalettes, Palette.ColorDepth depth,
            PatcherLib.Iso.KnownPosition imagePosition,
            PatcherLib.Iso.KnownPosition palettePosition,
            bool ignoreAssert = false)
            : base(name, width, height)
        {
            this.position        = imagePosition;
            this.palettePosition = palettePosition;
            this.depth           = depth;

            if (!ignoreAssert)
            {
                System.Diagnostics.Debug.Assert(palettePosition.Length == 256 * (int)depth * numPalettes);
            }

            if (position is PatcherLib.Iso.PsxIso.KnownPosition)
            {
                var pos = position as PatcherLib.Iso.PsxIso.KnownPosition;
                saveFileName = string.Format("{0}_{1}_{2}.bmp", pos.Sector, pos.StartLocation, pos.Length);
            }
            else if (position is PatcherLib.Iso.PspIso.KnownPosition)
            {
                var pos = position as PatcherLib.Iso.PspIso.KnownPosition;
                saveFileName = string.Format("{0}_{1}_{2}.bmp", pos.SectorEnum, pos.StartLocation, pos.Length);
            }
        }
        public PartiallyVisiblePalettedImage4bpp(
            string name,
            int width, int height,
            int numPalettes,
            Rectangle visiblePortion,
            FFTPatcher.SpriteEditor.Palette.ColorDepth depth,
            PatcherLib.Iso.KnownPosition imagePosition,
            PatcherLib.Iso.KnownPosition palettePosition )
            : base(name, visiblePortion.Width, visiblePortion.Height)
        {
            VisiblePortion = visiblePortion;
            FullSize = new Size( width, height );
            this.position = imagePosition;
            this.palettePosition = palettePosition;
            this.depth = depth;

            System.Diagnostics.Debug.Assert( palettePosition.Length == 8 * (int)depth * 2 );
            if ( position is PatcherLib.Iso.PsxIso.KnownPosition )
            {
                var pos = position as PatcherLib.Iso.PsxIso.KnownPosition;
                saveFileName = string.Format( "{0}_{1}.png", pos.Sector, pos.StartLocation );
            }
            else if ( position is PatcherLib.Iso.PspIso.KnownPosition )
            {
                var pos = position as PatcherLib.Iso.PspIso.KnownPosition;
                saveFileName = string.Format( "{0}_{1}.png", pos.SectorEnum, pos.StartLocation );
            }
        }
示例#3
0
        protected IList <byte> GetPaletteBytes(Set <Color> colors, Palette.ColorDepth depth)
        {
            List <byte> result = new List <byte>();

            if (depth == Palette.ColorDepth._16bit)
            {
                foreach (Color c in colors)
                {
                    result.AddRange(Palette.ColorToBytes(c));
                }
            }
            else if (depth == Palette.ColorDepth._32bit)
            {
                foreach (Color c in colors)
                {
                    result.Add(c.R);
                    result.Add(c.G);
                    result.Add(c.B);
                    result.Add(c.A);
                }
            }

            result.AddRange(new byte[Math.Max(0, (int)depth * 256 - result.Count)]);
            return(result);
        }
示例#4
0
 public PalettedImage4bpp(
     string name,
     int width, int height,
     int numPalettes,
     FFTPatcher.SpriteEditor.Palette.ColorDepth depth,
     PatcherLib.Iso.KnownPosition imagePosition,
     PatcherLib.Iso.KnownPosition palettePosition )
     : base(name, width, height)
 {
     this.position = imagePosition;
     this.palettePosition = palettePosition;
     this.depth = depth;
     System.Diagnostics.Debug.Assert( palettePosition.Length == 8 * (int)depth * 2 );
     if ( position is PatcherLib.Iso.PsxIso.KnownPosition )
     {
         var pos = position as PatcherLib.Iso.PsxIso.KnownPosition;
         saveFileName = string.Format( "{0}_{1}_{2}.bmp", pos.Sector, pos.StartLocation, pos.Length );
     }
     else if ( position is PatcherLib.Iso.PspIso.KnownPosition )
     {
         var pos = position as PatcherLib.Iso.PspIso.KnownPosition;
         saveFileName = string.Format( "{0}_{1}_{2}.bmp", pos.SectorEnum, pos.StartLocation, pos.Length );
     }
 }
示例#5
0
        public List <byte> GetPaletteBytes(IList <Color> colors, IList <byte> originalPaletteBytes, Palette.ColorDepth depth)
        {
            List <byte> result = new List <byte>();
            int         index  = 0;

            foreach (Color c in colors)
            {
                byte alphaByte = (depth == Palette.ColorDepth._32bit ? originalPaletteBytes[index * 4 + 3] : originalPaletteBytes[index * 2 + 1]);
                result.AddRange(Palette.ColorToBytes(c, alphaByte, depth));
                index++;
            }

            if (colors[0] == Color.Transparent)
            {
                result[0] = 0x00;
                result[1] = 0x00;
            }

            return(result);
        }
示例#6
0
        /*
         * public virtual Image Export()
         * {
         *  return ToBitmap();
         * }
         */

        public List <byte> GetPaletteBytes(IEnumerable <Palette> palettes, IList <byte> originalPaletteBytes, Palette.ColorDepth depth)
        {
            List <byte> result = new List <byte>();

            int paletteIndex = 0;

            foreach (Palette palette in palettes)
            {
                int colorSize   = (depth == Palette.ColorDepth._32bit) ? 4 : 2;
                int paletteSize = colorSize * palette.Colors.Length;
                result.AddRange(GetPaletteBytes(palette.Colors, originalPaletteBytes.SubLength(paletteSize * paletteIndex, paletteSize), depth));
                paletteIndex++;
            }

            return(result);
        }
 public PalettedImage8bppSectioned(
     string name, int width, int height, int numPalettes, Palette.ColorDepth depth, PatcherLib.Iso.KnownPosition imagePosition, PatcherLib.Iso.KnownPosition palettePosition,
     bool ignoreAssert = false)
     : base(name, width, height, numPalettes, depth, imagePosition, palettePosition, ignoreAssert)
 {
 }
示例#8
0
        public static PalettedImage4bpp ConstructFromXml( XmlNode node )
        {
            ImageInfo info = GetImageInfo( node );
            var palPos = GetPalettePositionFromImageNode( info.Sector, node );
            var pos = GetPositionFromImageNode( info.Sector, node );
            FFTPatcher.SpriteEditor.Palette.ColorDepth depth = Palette.ColorDepth._16bit;

            var cdNode = node.SelectSingleNode( "ColorDepth" );
            if (cdNode != null)
            {
                depth = (Palette.ColorDepth)Enum.Parse( typeof( Palette.ColorDepth ), cdNode.InnerText );
            }

            PalettedImage4bpp image = new PalettedImage4bpp( info.Name, info.Width, info.Height, 1, depth, pos, palPos );
            image.PaletteCount = info.PaletteCount;
            image.DefaultPalette = info.DefaultPalette;
            image.CurrentPalette = info.CurrentPalette;
            image.OriginalFilename = info.OriginalFilename;
            image.Filesize = info.Filesize;
            image.Sector = info.Sector;

            return image;
        }