void DrawSelectedAnime()
        {
            uint showSectionData = U.atoh(ShowSectionCombo.Text) - 1;
            uint showFrameData   = (uint)ShowFrameUpDown.Value;
            int  paletteIndex    = (int)ShowPaletteComboBox.SelectedIndex;

            uint sectionData    = (uint)N_P12.Value;
            uint frameData      = (uint)N_P16.Value;
            uint rightToLeftOAM = (uint)N_P20.Value;
            uint leftToRightOAM = (uint)N_P24.Value;
            uint palettes       = (uint)N_P28.Value;

            if (ShowDirectionComboBox.SelectedIndex == 1)
            {//敵軍の位置を表示
                rightToLeftOAM = leftToRightOAM;
            }

            Bitmap bitmap = ImageUtilOAM.DrawBattleAnime(showSectionData, showFrameData
                                                         , sectionData, frameData, rightToLeftOAM, palettes);

            if (paletteIndex > 0)
            {
                bitmap = ImageUtil.SwapPalette(bitmap, paletteIndex);
            }

            bool errorOver16Anime;
            int  palette_count = ImageUtil.GetPalette16Count(bitmap);

            if (palette_count >= 2)
            {
                errorOver16Anime = true;
            }
            else
            {
                errorOver16Anime = false;
            }
            UpdateLZ77Info(errorOver16Anime);

            X_B_ANIME_PIC2.Image = bitmap;
        }
        void DrawSelectedAnime()
        {
            uint showSectionData = U.atoh(ShowSectionCombo.Text) - 1;
            uint showFrameData   = (uint)ShowFrameUpDown.Value;
            int  paletteIndex    = (int)ShowPaletteComboBox.SelectedIndex;

            uint sectionData    = (uint)N_P12.Value;
            uint frameData      = (uint)N_P16.Value;
            uint rightToLeftOAM = (uint)N_P20.Value;
            uint leftToRightOAM = (uint)N_P24.Value;
            uint palettes       = (uint)N_P28.Value;

            if (ShowDirectionComboBox.SelectedIndex == 1)
            {//敵軍の位置を表示
                rightToLeftOAM = leftToRightOAM;
            }

            Bitmap bitmap = ImageUtilOAM.DrawBattleAnime(showSectionData, showFrameData
                                                         , sectionData, frameData, rightToLeftOAM, palettes);

            if (paletteIndex > 0)
            {
                bitmap = ImageUtil.SwapPalette(bitmap, paletteIndex);
            }

            int palette_count = ImageUtil.GetPalette16Count(bitmap);

            if (palette_count >= 2)
            {
                ERROR_OVER16_ANIME.Show();
            }
            else
            {
                ERROR_OVER16_ANIME.Hide();
            }

            X_B_ANIME_PIC2.Image = bitmap;
        }
        public static Bitmap DrawBattleAnime(uint id, ScaleTrim trim = ScaleTrim.SCALE_90, uint custompalette = 0, uint showSectionData = 0, uint showFrameData = 0, int showPaletteIndex = 0)
        {
            if (id <= 0)
            {
                return(ImageUtil.BlankDummy());
            }
            id = id - 1; //anime IDは 1 からスタート.

            InputFormRef InputFormRef = N_Init(null);
            uint         addr         = InputFormRef.IDToAddr(id);

            if (!U.isSafetyOffset(addr))
            {
                return(ImageUtil.BlankDummy());
            }

            uint sectionData    = Program.ROM.u32(addr + 12);
            uint frameData      = Program.ROM.u32(addr + 16);
            uint rightToLeftOAM = Program.ROM.u32(addr + 20);
            uint palettes       = Program.ROM.u32(addr + 28);

            if (custompalette > 0)
            {
                uint p = ImageUnitPaletteForm.GetPaletteAddr(custompalette);
                if (U.isSafetyOffset(addr))
                {
                    palettes = p;
                }
            }

            Bitmap bitmap = ImageUtilOAM.DrawBattleAnime(showSectionData, showFrameData
                                                         , sectionData, frameData, rightToLeftOAM, palettes);

            if (showPaletteIndex > 0)
            {
                bitmap = ImageUtil.SwapPalette(bitmap, showPaletteIndex);
            }


            if (trim == ScaleTrim.SCALE_48)
            {
                Bitmap trimBitmap = ImageUtil.Blank(48, 48, bitmap);
                ImageUtil.BitBlt(trimBitmap, 0, 0, trimBitmap.Width, trimBitmap.Height, bitmap
                                 , 125, 58);
                bitmap.Dispose();
                return(trimBitmap);
            }
            else if (trim == ScaleTrim.SCALE_90)
            {
                Bitmap trimBitmap = ImageUtil.Blank(90, 90, bitmap);
                ImageUtil.BitBlt(trimBitmap, 0, 0, trimBitmap.Width, trimBitmap.Height, bitmap
                                 , 100, 30);
                bitmap.Dispose();
                return(trimBitmap);
            }
            else if (trim == ScaleTrim.NO_BUT_FLIP)
            {
                Bitmap flipBitmap = ImageUtil.Copy(bitmap, 0, 0, bitmap.Width - 8, bitmap.Height, true);
                bitmap.Dispose();
                return(flipBitmap);
            }
            else
            {
                return(bitmap);
            }
        }