Beispiel #1
0
        public static void ReplaceTexture(Image newImage, TextureListObject textureListObject)
        {
            ImageHeader   imageHeader   = textureListObject.imageHeader;
            PaletteHeader paletteHeader = textureListObject.paletteHeader;

            byte[] newPaletteData;
            byte[] newTextureData = TPL.ConvertToTextureMelee(newImage, textureListObject, out newPaletteData);

            if (newTextureData.Length != textureListObject.imageSize)
            {
                MessageBox.Show("Error: Selected image is not the same file size!");
                return;
            }

            if (paletteHeader != null && newPaletteData.Length > paletteHeader.colorCount0xC * 2)
            {
                MessageBox.Show(
                    "The selected image contains more colors than the original image. Please use no more than " + paletteHeader.colorCount0xC + " colors.");
                return;
            }

            Array.ConstrainedCopy(newTextureData, 0, file, (int)(imageHeader.imageOffset0x0 + dataOffset), newTextureData.Length);
            if (paletteHeader != null)
            {
                Array.ConstrainedCopy(newPaletteData, 0, file, (int)(paletteHeader.paletteOffset0x0 + dataOffset), Math.Min((paletteHeader.colorCount0xC * 2), newPaletteData.Length));
            }
            OpenDatFile(file, fileName, ref textureList);
        }
 public TextureListObject(UInt32 imageHeaderOffset, TextureNode node)
 {
     name          = "Texture " + (DatFile.textureList.Items.Count + 1) + " (" + imageHeaderOffset.ToString("x8") + ")";
     this.node     = node;
     imageHeader   = node.imageHeader;
     paletteHeader = node.paletteHeader;
     imageBitmap   = TPL.ConvertFromTextureMelee(imageHeader, paletteHeader, out imageSize);
 }
Beispiel #3
0
        private static void BuildPaletteHeader(TreeNode parent, UInt32 offset, ref TextureNode texNode)
        {
            var newPaletteHeader = new PaletteHeader(file, offset);

            var newTreeNode = new TreeNode("PaletteHeader");

            newTreeNode.Tag = newPaletteHeader;
            parent.Nodes.Add(newTreeNode);
            texNode.paletteHeader = newPaletteHeader;
        }
        public TextureListObject(UInt32 imageHeaderOffset, TextureNode node)
        {
            name = "Texture " + (DatFile.textureList.Items.Count +1) + " (" + imageHeaderOffset.ToString("x8") + ")";
            this.node = node;
            imageHeader = node.imageHeader;
            paletteHeader = node.paletteHeader;
            imageBitmap = TPL.ConvertFromTextureMelee(imageHeader, paletteHeader, out imageSize);





        }
Beispiel #5
0
        private static void BuildPaletteHeader(TreeNode parent, UInt32 offset, ref TextureNode texNode)
        {
            var newPaletteHeader = new PaletteHeader(file, offset);

            var newTreeNode = new TreeNode("PaletteHeader");
            newTreeNode.Tag = newPaletteHeader;
            parent.Nodes.Add(newTreeNode);
            texNode.paletteHeader = newPaletteHeader;
        }