示例#1
0
        public static Npck FromBackgroundStreams(Stream nscrStr, Stream ncgrStr, Stream nclrStr)
        {
            Npck npck = new Npck();

            npck.AddSubfile(nclrStr);
            npck.AddSubfile(ncgrStr);
            npck.AddSubfile(null);                      // NCBR (NCGR lineal)
            npck.AddSubfile(null);                      // NCER
            npck.AddSubfile(null);                      // Unknown
            npck.AddSubfile(null);                      // NANR
            npck.AddSubfile(nscrStr);
            npck.AddSubfile(null);                      // Unknown
            npck.AddSubfile(null);                      // Unknown
            return(npck);
        }
示例#2
0
        public static Npck FromSpriteStreams(Stream ncerStr, Stream ncgrLinealStr,
                                             Stream ncgrTiledStr, Stream nclrStr, Stream nanrStr)
        {
            Npck npck = new Npck();

            npck.AddSubfile(nclrStr);
            npck.AddSubfile(ncgrTiledStr);
            npck.AddSubfile(ncgrLinealStr);
            npck.AddSubfile(ncerStr);
            npck.AddSubfile(null);                      // Unknown
            npck.AddSubfile(nanrStr);
            npck.AddSubfile(null);                      // NSCR
            npck.AddSubfile(null);                      // Unknown
            npck.AddSubfile(null);                      // Unknown
            return(npck);
        }
示例#3
0
        public static Npck ChangeTextureImages(EmguImage[] images, int[] frames, Palette palOut, Npck original)
        {
            // Get an original texture file to get images and the texture to modify
            long start = original[0].Position;

            Btx0 oriTexture = new Btx0(original[0]);

            original[0].Position = start;

            Btx0 newTexture = new Btx0(original[0]);

            original[0].Position = start;

            // Create importer and remove all images
            TextureImporter importer = new TextureImporter(newTexture);

            importer.RemoveImages();

            // Add images from arguments or original texture if not presents.
            List <int> frameList = frames.ToList();

            for (int i = 0; i < oriTexture.NumTextures; i++)
            {
                int idx = frameList.IndexOf(i);

                // Set quantization to original palette or argument palette
                Color[] originalPalette = oriTexture.GetPalette(i).GetPalette(0);
                if (idx != -1 && palOut != null)
                {
                    importer.Quantization = new FixedPaletteQuantization(palOut.GetPalette(idx));
                }
                else
                {
                    importer.Quantization = new FixedPaletteQuantization(originalPalette);
                }

                // Keep original color format and name
                string name = oriTexture.GetTextureName(i);
                importer.Format = oriTexture.GetImage(i).Format;

                // Keep original unknown values
                int[] texUnks = oriTexture.GetTextureUnknowns(i);
                int[] palUnks = oriTexture.GetPaletteUnknowns(i);

                // Import :D
                if (idx != -1)
                {
                    importer.AddImage(images[idx], name, texUnks, palUnks, originalPalette);
                }
                else
                {
                    importer.AddImage(oriTexture.CreateBitmap(i), name, texUnks, palUnks);
                }
            }

            // Write the new texture file
            MemoryStream textureStream = new MemoryStream();

            newTexture.Write(textureStream);
            textureStream.Position = 0;

            // Create a copy of the NPCK from the original
            Npck npck = new Npck();

            npck.AddSubfile(textureStream);
            for (int i = 1; i < 6; i++)
            {
                npck.AddSubfile(original[i]);
            }

            return(npck);
        }
示例#4
0
 public static Npck FromSpriteStreams(Stream ncerStr, Stream ncgrLinealStr,
     Stream ncgrTiledStr, Stream nclrStr, Stream nanrStr)
 {
     Npck npck = new Npck();
     npck.AddSubfile(nclrStr);
     npck.AddSubfile(ncgrTiledStr);
     npck.AddSubfile(ncgrLinealStr);
     npck.AddSubfile(ncerStr);
     npck.AddSubfile(null);		// Unknown
     npck.AddSubfile(nanrStr);
     npck.AddSubfile(null);		// NSCR
     npck.AddSubfile(null);		// Unknown
     npck.AddSubfile(null);		// Unknown
     return npck;
 }
示例#5
0
 public static Npck FromBackgroundStreams(Stream nscrStr, Stream ncgrStr, Stream nclrStr)
 {
     Npck npck = new Npck();
     npck.AddSubfile(nclrStr);
     npck.AddSubfile(ncgrStr);
     npck.AddSubfile(null);		// NCBR (NCGR lineal)
     npck.AddSubfile(null);		// NCER
     npck.AddSubfile(null);		// Unknown
     npck.AddSubfile(null);		// NANR
     npck.AddSubfile(nscrStr);
     npck.AddSubfile(null);		// Unknown
     npck.AddSubfile(null);		// Unknown
     return npck;
 }
示例#6
0
        public static Npck ChangeTextureImages(EmguImage[] images, int[] frames, Palette palOut, Npck original)
        {
            // Get an original texture file to get images and the texture to modify
            long start = original[0].Position;

            Btx0 oriTexture = new Btx0(original[0]);
            original[0].Position = start;

            Btx0 newTexture = new Btx0(original[0]);
            original[0].Position = start;

            // Create importer and remove all images
            TextureImporter importer = new TextureImporter(newTexture);
            importer.RemoveImages();

            // Add images from arguments or original texture if not presents.
            List<int> frameList = frames.ToList();
            for (int i = 0; i < oriTexture.NumTextures; i++) {
                int idx = frameList.IndexOf(i);

                // Set quantization to original palette or argument palette
                Color[] originalPalette = oriTexture.GetPalette(i).GetPalette(0);
                if (idx != -1 && palOut != null)
                    importer.Quantization = new FixedPaletteQuantization(palOut.GetPalette(idx));
                else
                    importer.Quantization = new FixedPaletteQuantization(originalPalette);

                // Keep original color format and name
                string name = oriTexture.GetTextureName(i);
                importer.Format = oriTexture.GetImage(i).Format;

                // Keep original unknown values
                int[] texUnks = oriTexture.GetTextureUnknowns(i);
                int[] palUnks = oriTexture.GetPaletteUnknowns(i);

                // Import :D
                if (idx != -1)
                    importer.AddImage(images[idx], name, texUnks, palUnks, originalPalette);
                else
                    importer.AddImage(oriTexture.CreateBitmap(i), name, texUnks, palUnks);
            }

            // Write the new texture file
            MemoryStream textureStream = new MemoryStream();
            newTexture.Write(textureStream);
            textureStream.Position = 0;

            // Create a copy of the NPCK from the original
            Npck npck = new Npck();
            npck.AddSubfile(textureStream);
            for (int i = 1; i < 6; i++)
                npck.AddSubfile(original[i]);

            return npck;
        }