Ejemplo n.º 1
0
        private void LoadImageFromLBXFile(LBXFile lbxFile, InternalFileClass internalFile)
        {
            currentBitmaps = internalFile.GetBitmaps(lbxFile);

            if (currentBitmaps.Length > 1)
            {
                framesBar.Enabled = true;
                framesBar.SetRange(0, currentBitmaps.Length - 1);
            }
            else
            {
                framesBar.Enabled = false;
                framesBar.SetRange(0, 1);
            }
            framesBar.Value = 0;

            widthLabel.Text  = "Width: " + internalFile.Width;
            heightLabel.Text = "Height: " + internalFile.Height;
            frameLabel.Text  = "Frames: " + internalFile.Frames;

            pictureBox1.Image = currentBitmaps[0];
            pictureBox1.Refresh();

            exportImagesButton.Enabled = true;

            textPreviewTextBox.Text = string.Empty;
        }
Ejemplo n.º 2
0
        private void exportImagesButton_Click(object sender, EventArgs e)
        {
            if (currentBitmaps == null)             //Sanity check
            {
                return;
            }
            using (FolderBrowserDialog folderBrowser = new FolderBrowserDialog())
            {
                if (folderBrowser.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        var selectedNode = lbxFilesTreeView.SelectedNode;
                        InternalFileClass internalFile = selectedNode.Tag as InternalFileClass;

                        for (int i = 0; i < currentBitmaps.Length; i++)
                        {
                            currentBitmaps[i].Save(Path.Combine(folderBrowser.SelectedPath, internalFile.FileName + i + ".BMP"));
                        }
                    }
                    catch (Exception exception)
                    {
                        MessageBox.Show(exception.Message);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Load the image or text or clear out everything if unknown
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void lbxFilesTreeView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            var selectedNode = e.Node;

            //Determine if this was an internal file or LBX file

            if (selectedNode.Nodes.Count > 0)             //Parent LBX file, don't do anything
            {
                return;
            }
            InternalFileClass internalFile = selectedNode.Tag as InternalFileClass;

            if (internalFile != null)
            {
                //An image file
                LBXFile lbxFile = selectedNode.Parent.Tag as LBXFile;
                if (lbxFile != null)                 //Sanity check
                {
                    LoadImageFromLBXFile(lbxFile, internalFile);
                }
                else
                {
                    MessageBox.Show(this, "I dunno what happened, but apparently parent node doesn't have LBX File loaded", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            else
            {
                //Probably a text file
                LBXFile lbxFile = selectedNode.Tag as LBXFile;
                LoadTextFromLBXFile(lbxFile);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Loads the internal files' names, start and end positions in byte array
        /// </summary>
        private void LoadFiles()
        {
            internalFiles = new List <InternalFileClass>();
            for (int i = 0; i < numOfInternalFiles; i++)
            {
                InternalFileClass newFile = new InternalFileClass();
                if (LBXFileType == LBXFileTypeEnum.IMAGE)
                {
                    char[] name    = new char[8];
                    char[] comment = new char[24];
                    for (int k = 0; k < 8; k++)
                    {
                        name[k] = lookup[(char)bytes[512 + (i * 32) + k]] ? (char)bytes[512 + (i * 32) + k] : ' ';
                    }
                    for (int k = 0; k < 24; k++)
                    {
                        comment[k] = lookup[(char)bytes[520 + (i * 32) + k]] ? (char)bytes[520 + (i * 32) + k] : ' ';
                    }
                    newFile.Comment  = new string(comment);
                    newFile.FileName = new string(name);
                }
                else
                {
                    newFile.FileName = "File " + (i + 1);
                }
                int currentPos = 8 + (i * 4);
                //Unsigned integers are stored backwards (4 bytes per integer), so read from left to right, while multiplying each byte's value by 256^i, with i starting at 0, to get the real value
                newFile.StartPos = bytes[currentPos + 0] + (uint)(bytes[currentPos + 1] * FirstPower) + (uint)(bytes[currentPos + 2] * SecondPower) +
                                   (uint)(bytes[currentPos + 3] * ThirdPower);
                newFile.EndPos = bytes[currentPos + 4] + (uint)(bytes[currentPos + 5] * FirstPower) + (uint)(bytes[currentPos + 6] * SecondPower) +
                                 (uint)(bytes[currentPos + 7] * ThirdPower);

                internalFiles.Add(newFile);
            }
        }