public static byte[] GetImage(P3D.Chunk image)
        {
            int offset    = 0;
            int imageSize = Utility.Byte4ToInt(Utility.GetRange(image.Data, offset, 4), 0);

            offset += 4;
            byte[] imageB = Utility.GetRange(image.Data, offset, imageSize);
            return(imageB);
        }
Exemple #2
0
        public static ImageDataStruct GetImageData(P3D.Chunk imageDataChunk)
        {
            ImageDataStruct imageData  = new ImageDataStruct();
            int             offset     = 0;
            int             nameLength = imageDataChunk.Data[offset++];

            imageData.Name       = System.Text.Encoding.UTF8.GetString(Utility.GetRange(imageDataChunk.Data, offset, nameLength));
            offset              += nameLength;
            imageData.version    = Utility.Byte4ToInt(imageDataChunk.Data, offset); offset += 4;
            imageData.width      = Utility.Byte4ToInt(imageDataChunk.Data, offset); offset += 4;
            imageData.height     = Utility.Byte4ToInt(imageDataChunk.Data, offset); offset += 4;
            imageData.bitDepth   = Utility.Byte4ToInt(imageDataChunk.Data, offset); offset += 4;
            imageData.palaetised = Utility.Byte4ToInt(imageDataChunk.Data, offset); offset += 4;
            imageData.hasAlpha   = Utility.Byte4ToInt(imageDataChunk.Data, offset); offset += 4;
            imageData.format     = Utility.Byte4ToInt(imageDataChunk.Data, offset);
            return(imageData);
        }
Exemple #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (treeView1.SelectedNode == null)
            {
                MessageBox.Show("No sprite is selected!");
                return;
            }
            else if (treeView1.SelectedNode.BackColor == Color.Green)
            {
                MessageBox.Show("Sprite is already divided!");
                return;
            }
            P3D.Chunk chunk = (P3D.Chunk)treeView1.SelectedNode.Tag;
            chunk = p.DivideSprite(chunk);
            p.Root.subChunks[chunk.Index] = chunk;

            treeView1.SelectedNode.BackColor = Color.Green;
        }
Exemple #4
0
        public static TextureDataStruct GetTextureData(P3D.Chunk texture)
        {
            TextureDataStruct textureData = new TextureDataStruct();
            int offset     = 0;
            int nameLength = texture.Data[offset++];

            textureData.Name        = System.Text.Encoding.UTF8.GetString(Utility.GetRange(texture.Data, offset, nameLength));
            offset                 += nameLength;
            textureData.version     = Utility.Byte4ToInt(texture.Data, offset); offset += 4;
            textureData.width       = Utility.Byte4ToInt(texture.Data, offset); offset += 4;
            textureData.height      = Utility.Byte4ToInt(texture.Data, offset); offset += 4;
            textureData.bitDepth    = Utility.Byte4ToInt(texture.Data, offset); offset += 4;
            textureData.alphaDepth  = Utility.Byte4ToInt(texture.Data, offset); offset += 4;
            textureData.mipMapCount = Utility.Byte4ToInt(texture.Data, offset); offset += 4;
            textureData.textureType = Utility.Byte4ToInt(texture.Data, offset); offset += 4;
            textureData.usage       = Utility.Byte4ToInt(texture.Data, offset); offset += 4;
            textureData.priority    = Utility.Byte4ToInt(texture.Data, offset);
            return(textureData);
        }
        public static SpriteDataChunk GetSpriteData(P3D.Chunk sprite)
        {
            SpriteDataChunk spriteData = new SpriteDataChunk();
            int             offset     = 0;
            int             nameLength = sprite.Data[offset++];

            spriteData.Name = System.Text.Encoding.UTF8.GetString(Utility.GetRange(sprite.Data, offset, nameLength));
            offset         += nameLength;

            spriteData.NativeX = Utility.Byte4ToInt(sprite.Data, offset); offset += 4;
            spriteData.NativeY = Utility.Byte4ToInt(sprite.Data, offset); offset += 4;

            int shaderLength = sprite.Data[offset++];

            spriteData.Shader = System.Text.Encoding.UTF8.GetString(Utility.GetRange(sprite.Data, offset, shaderLength));
            offset           += shaderLength;

            spriteData.ImageWidth  = Utility.Byte4ToInt(sprite.Data, offset); offset += 4;
            spriteData.ImageHeight = Utility.Byte4ToInt(sprite.Data, offset); offset += 4;
            spriteData.ImageCount  = Utility.Byte4ToInt(sprite.Data, offset); offset += 4;
            spriteData.BlitBorder  = Utility.Byte4ToInt(sprite.Data, offset);

            return(spriteData);
        }