示例#1
0
 private void sb_importImage_Click(object sender, EventArgs e)
 {
     if (sb_imageBox.BackgroundImage != null)
     {
         OpenFileDialog openImgDialog = new OpenFileDialog();
         openImgDialog.Filter = "PNG|*.png|JPEG|*.jpg|BMP|*.bmp";
         DialogResult result = openImgDialog.ShowDialog();
         if (result == DialogResult.OK) // Test result.
         {
             Bitmap img = (Bitmap)sb_imageBox.BackgroundImage;
             if (tabPage3.Text.Equals("End Cake Image"))
             {
                 // img = new Bitmap(Image.FromFile(openImgDialog.FileName), new Size(316, 228));
                 // LargeImageLoader.importCakeImage(ref img, 0x07000000);
             }
             else
             {
                 int segA_size     = ROM.Instance.getSegment(0xA, (byte)level.CurrentAreaID).Length;
                 int skybox_width  = 248;
                 int skybox_height = ((segA_size - 0x140) / 256 / 2 / 32) * 31;
                 img = new Bitmap(Image.FromFile(openImgDialog.FileName), new Size(skybox_width, skybox_height));
                 LargeImageLoader.importSkyboxImage(ref img, 0x0A000000);
             }
             sb_imageBox.BackgroundImage = img;
         }
     }
 }
示例#2
0
        private void updateSkyboxImageInfo(int sizeOfSegmentA)
        {
            int    skybox_width  = 248;
            int    skybox_height = ((sizeOfSegmentA - 0x140) / 256 / 2 / 32) * 31;
            Bitmap org           = LargeImageLoader.getSkyboxImage(0x0A000000, skybox_width, skybox_height);

            if (org != null)
            {
                string[] tags = (string[])org.Tag;
                foreach (string tag in tags)
                {
                    if (tag.StartsWith("Width:"))
                    {
                        sb_info_Width.Text = tag;
                    }
                    else if (tag.StartsWith("Height:"))
                    {
                        sb_info_Height.Text = tag;
                    }
                    else if (tag.StartsWith("Format:"))
                    {
                        sb_info_Format.Text = tag;
                    }
                    else if (tag.StartsWith("Seg Addr:"))
                    {
                        sb_info_SegAddress.Text = tag;
                    }
                    else if (tag.StartsWith("ROM Address:"))
                    {
                        sb_info_RomAddress.Text = tag;
                    }
                }
            }
        }
示例#3
0
        private void updateSkyboxTexture()
        {
            int    sizeOfSegmentA = ROM.Instance.getSegment(0xA, (byte)level.CurrentAreaID).Length;
            int    skybox_width   = 248;
            int    skybox_height  = ((sizeOfSegmentA - 0x140) / 256 / 2 / 32) * 31;
            Bitmap org            = LargeImageLoader.getSkyboxImage(0x0A000000, skybox_width, skybox_height);

            if (org == null)
            {
                return;
            }
            sb_imageBox.BackgroundImage     = new Bitmap(org, skybox_width, skybox_height);
            sb_imageBox.BackgroundImage.Tag = org.Tag;
            if (sb_imageBox.BackgroundImage != null)
            {
                sb_imageBox.BackgroundImageLayout = ImageLayout.Center;
                tabPage3.Text = "Sky Background";
            }
        }
示例#4
0
        private void loadBackgroundImage()
        {
            sb_useTexture.Enabled = true;
            LevelInfo.AreaBackgroundInfo bgInfo = level.getCurrentArea().bgInfo;
            checkBox_matchFogColor.Enabled = bgInfo.usesFog && (bgInfo.fogColor_romLocation.Count > 0);
            //Console.WriteLine("BG info address = 0x{0}", bgInfo.address.ToString("X8"));

            int segA_size = 0;

            if (bgInfo.address != 0)
            {
                byte[] segA_data = ROM.Instance.getSegment(0xA, (byte)level.CurrentAreaID);
                if (segA_data != null)
                {
                    segA_size = segA_data.Length;
                }
            }
            // Console.WriteLine("Segment 0xA size: " + ROM.Instance.getSegment(0xA).Length);
            if (segA_size == 0)
            {
                sb_useTexture.Enabled = false;
            }
            else
            {
                sb_useTexture.Enabled = true;
                updateSkyboxImageInfo(segA_size);
            }

            if (bgInfo.address == 0 && !bgInfo.isEndCakeImage)
            {
                sb_imageBox.BackgroundImage       = new Bitmap(200, 200);
                sb_imageBox.BackgroundImageLayout = ImageLayout.Center;
                ushort color = bgInfo.id_or_color;
                updateBoxColor(color);
                sb_useSolidColor.Checked    = true;
                numericUpDown_Red.Enabled   = true;
                numericUpDown_Green.Enabled = true;
                numericUpDown_Blue.Enabled  = true;
                sb_importImage.Enabled      = false;
                sb_exportImage.Enabled      = false;
                int red   = (color >> 11) & 31;
                int green = (color >> 6) & 31;
                int blue  = (color >> 1) & 31;
                numericUpDown_Red.Value   = red;
                numericUpDown_Green.Value = green;
                numericUpDown_Blue.Value  = blue;
            }
            else if (segA_size > 0)
            {
                sb_useTexture.Checked       = true;
                numericUpDown_Red.Enabled   = false;
                numericUpDown_Green.Enabled = false;
                numericUpDown_Blue.Enabled  = false;
                sb_importImage.Enabled      = true;
                sb_exportImage.Enabled      = true;
                tabControl1.TabPages.Remove(tabPage3);
                if (bgInfo.isEndCakeImage)
                {
                    /*
                     * Bitmap org = LargeImageLoader.getCakeImage(0x07000000);
                     * if (org == null)
                     *  return;
                     * sb_imageBox.BackgroundImage = new Bitmap(org, 316, 228);
                     * sb_imageBox.BackgroundImage.Tag = org.Tag;
                     * if (sb_imageBox.BackgroundImage != null)
                     * {
                     *  sb_imageBox.BackgroundImageLayout = ImageLayout.Center;
                     *  tabPage3.Text = "End Cake Image";
                     * }*/
                }
                else
                {
                    tabControl1.TabPages.Add(tabPage3);
                    int    skybox_width  = 248;
                    int    skybox_height = ((segA_size - 0x140) / 256 / 2 / 32) * 31;
                    Bitmap org           = LargeImageLoader.getSkyboxImage(0x0A000000, skybox_width, skybox_height);
                    if (org == null)
                    {
                        return;
                    }
                    sb_imageBox.BackgroundImage     = new Bitmap(org, skybox_width, skybox_height);
                    sb_imageBox.BackgroundImage.Tag = org.Tag;
                    if (sb_imageBox.BackgroundImage != null)
                    {
                        sb_imageBox.BackgroundImageLayout = ImageLayout.Center;
                        tabPage3.Text = "Sky Background";
                    }
                }
            }
        }