Пример #1
0
        private void Draw()
        {
            byte[] image;
            int    image_pos;

            if (ImageOption.SelectedIndex == 0 || ImageOption.SelectedIndex == 3)
            {//圧縮画像
                image = LZ77.decompress(Program.ROM.Data
                                        , U.toOffset((uint)Image.Value));
                image_pos = 0;
                if (image.Length <= 2)
                {
                    X_BG_PIC.Image = null;
                    this.USE_PALETTE_NUMBER.Text = "1";
                    this.DrawBimap = null;
                    return;
                }
            }
            else if (ImageOption.SelectedIndex == 2)
            {//第2圧縮画像
                image = LZ77.decompress(Program.ROM.Data, U.toOffset((uint)Image.Value));
                byte[] image2 = LZ77.decompress(Program.ROM.Data, U.toOffset((uint)Image2.Value));
                image_pos = 0;
                if (image.Length <= 2)
                {
                    X_BG_PIC.Image = null;
                    this.USE_PALETTE_NUMBER.Text = "1";
                    this.DrawBimap = null;
                    return;
                }
                if (image2.Length > 2)
                {
                    List <byte> imageUZList = new List <byte>();
                    imageUZList.AddRange(image);
                    imageUZList.AddRange(image2);

                    image = imageUZList.ToArray();
                }
            }
            else
            {//無圧縮画像
                image     = Program.ROM.Data;
                image_pos = (int)U.toOffset((uint)Image.Value);
            }

            byte[] tsa;
            int    tsa_pos;

            if (TSAOption.SelectedIndex == 0)
            {//TSAを利用しない
                tsa     = null;
                tsa_pos = 0;

                Bitmap bitmap;
                if (ImageOption.SelectedIndex == 3)
                {///256
                    bitmap = ImageUtil.ByteToImage256Tile((int)PicWidth.Value * 8
                                                          , (int)PicHeight.Value * 8
                                                          , image
                                                          , image_pos
                                                          , Program.ROM.Data
                                                          , (int)ToPaletteOffset((uint)PALETTE.Value, (uint)PALETTENO.Value)
                                                          );
                    this.USE_PALETTE_NUMBER.Text = "16";
                }
                else
                {
                    bitmap = ImageUtil.ByteToImage16Tile((int)PicWidth.Value * 8
                                                         , (int)PicHeight.Value * 8
                                                         , image
                                                         , image_pos
                                                         , Program.ROM.Data
                                                         , (int)ToPaletteOffset((uint)PALETTE.Value, (uint)PALETTENO.Value)
                                                         , 0
                                                         );
                    this.USE_PALETTE_NUMBER.Text = ImageUtil.GetPalette16Count(bitmap).ToString();
                }
                X_BG_PIC.Image = U.Zoom(bitmap, ZoomComboBox.SelectedIndex);
                this.DrawBimap = bitmap;
            }
            else if (TSAOption.SelectedIndex == 1)
            {//圧縮TSAを利用する
                tsa     = LZ77.decompress(Program.ROM.Data, U.toOffset((uint)TSA.Value));
                tsa_pos = 0;

                if (tsa.Length <= 2)
                {
                    X_BG_PIC.Image = ImageUtil.BlankDummy();
                    return;
                }
                Bitmap bitmap;
                if (ImageOption.SelectedIndex == 3)
                {///256
                    bitmap = ImageUtil.ByteToImage256Tile((int)PicWidth.Value * 8
                                                          , (int)PicHeight.Value * 8
                                                          , image
                                                          , image_pos
                                                          , Program.ROM.Data
                                                          , (int)ToPaletteOffset((uint)PALETTE.Value, (uint)PALETTENO.Value)
                                                          , tsa
                                                          , tsa_pos
                                                          );
                    this.USE_PALETTE_NUMBER.Text = "16";
                }
                else
                {
                    bitmap = ImageUtil.ByteToImage16Tile((int)PicWidth.Value * 8
                                                         , (int)PicHeight.Value * 8
                                                         , image
                                                         , image_pos
                                                         , Program.ROM.Data
                                                         , (int)ToPaletteOffset((uint)PALETTE.Value, (uint)PALETTENO.Value)
                                                         , tsa
                                                         , tsa_pos
                                                         , 0
                                                         );
                    this.USE_PALETTE_NUMBER.Text = ImageUtil.GetPalette16CountForTSA(tsa, (uint)tsa_pos, (uint)(PicWidth.Value * PicHeight.Value)).ToString();
                }
                X_BG_PIC.Image = U.Zoom(bitmap, ZoomComboBox.SelectedIndex);
                this.DrawBimap = bitmap;
            }
            else if (TSAOption.SelectedIndex == 2)
            {//圧縮ヘッダ付きTSAを利用する
                tsa     = LZ77.decompress(Program.ROM.Data, U.toOffset((uint)TSA.Value));
                tsa_pos = 0;
                if (tsa.Length <= 2)
                {
                    X_BG_PIC.Image = ImageUtil.BlankDummy();
                    return;
                }

                Bitmap bitmap;
                if (ImageOption.SelectedIndex == 3)
                {///256
                    bitmap = ImageUtil.ByteToImage256TileHeaderTSA((int)PicWidth.Value * 8, (int)PicHeight.Value * 8, image, image_pos, Program.ROM.Data, (int)ToPaletteOffset((uint)PALETTE.Value, (uint)PALETTENO.Value), tsa, tsa_pos);
                    this.USE_PALETTE_NUMBER.Text = "16";
                }
                else
                {
                    bitmap = ImageUtil.ByteToImage16TileHeaderTSA((int)PicWidth.Value * 8, (int)PicHeight.Value * 8, image, image_pos, Program.ROM.Data, (int)ToPaletteOffset((uint)PALETTE.Value, (uint)PALETTENO.Value), tsa, tsa_pos);
                    this.USE_PALETTE_NUMBER.Text = ImageUtil.GetPalette16CountForTSA(tsa, (uint)tsa_pos + 2, (uint)(PicWidth.Value * PicHeight.Value)).ToString();
                }
                X_BG_PIC.Image = U.Zoom(bitmap, ZoomComboBox.SelectedIndex);
                this.DrawBimap = bitmap;
            }
            else if (TSAOption.SelectedIndex == 3)
            {//無圧縮ヘッダ付きTSAを利用する
                tsa     = Program.ROM.Data;
                tsa_pos = (int)U.toOffset((uint)TSA.Value);

                Bitmap bitmap;
                if (ImageOption.SelectedIndex == 3)
                {///256
                    bitmap = ImageUtil.ByteToImage256TileHeaderTSA((int)PicWidth.Value * 8, (int)PicHeight.Value * 8, image, image_pos, Program.ROM.Data, (int)ToPaletteOffset((uint)PALETTE.Value, (uint)PALETTENO.Value), tsa, tsa_pos);
                    this.USE_PALETTE_NUMBER.Text = "16";
                }
                else
                {
                    bitmap = ImageUtil.ByteToImage16TileHeaderTSA((int)PicWidth.Value * 8, (int)PicHeight.Value * 8, image, image_pos, Program.ROM.Data, (int)ToPaletteOffset((uint)PALETTE.Value, (uint)PALETTENO.Value), tsa, tsa_pos);
                    this.USE_PALETTE_NUMBER.Text = ImageUtil.GetPalette16CountForTSA(tsa, (uint)tsa_pos + 2, (uint)(PicWidth.Value * PicHeight.Value)).ToString();
                }
                X_BG_PIC.Image = U.Zoom(bitmap, ZoomComboBox.SelectedIndex);
                this.DrawBimap = bitmap;
            }
            else if (TSAOption.SelectedIndex == 4)
            {//無圧縮TSAを利用する
                tsa     = Program.ROM.Data;
                tsa_pos = (int)U.toOffset((uint)TSA.Value);

                Bitmap bitmap;
                if (ImageOption.SelectedIndex == 3)
                {///256
                    bitmap = ImageUtil.ByteToImage256Tile((int)PicWidth.Value * 8, (int)PicHeight.Value * 8, image, image_pos, Program.ROM.Data, (int)ToPaletteOffset((uint)PALETTE.Value, (uint)PALETTENO.Value), tsa, tsa_pos);
                    this.USE_PALETTE_NUMBER.Text = "16";
                }
                else
                {
                    bitmap = ImageUtil.ByteToImage16Tile((int)PicWidth.Value * 8, (int)PicHeight.Value * 8, image, image_pos, Program.ROM.Data, (int)ToPaletteOffset((uint)PALETTE.Value, (uint)PALETTENO.Value), tsa, tsa_pos);
                    this.USE_PALETTE_NUMBER.Text = ImageUtil.GetPalette16CountForTSA(tsa, (uint)tsa_pos, (uint)(PicWidth.Value * PicHeight.Value)).ToString();
                }
                X_BG_PIC.Image = U.Zoom(bitmap, ZoomComboBox.SelectedIndex);
                this.DrawBimap = bitmap;
            }
            else if (TSAOption.SelectedIndex == 5)
            {//パレットマップとして解釈する
                tsa     = Program.ROM.Data;
                tsa_pos = (int)U.toOffset((uint)TSA.Value);

                Bitmap bitmap = ImageUtil.ByteToImage16TilePaletteMap((int)PicWidth.Value * 8
                                                                      , (int)PicHeight.Value * 8
                                                                      , image
                                                                      , image_pos
                                                                      , Program.ROM.Data
                                                                      , (int)ToPaletteOffset((uint)PALETTE.Value, (uint)PALETTENO.Value)
                                                                      , tsa
                                                                      , tsa_pos
                                                                      );
                X_BG_PIC.Image = U.Zoom(bitmap, ZoomComboBox.SelectedIndex);
                this.USE_PALETTE_NUMBER.Text = "4";
                this.DrawBimap = bitmap;
            }
            else
            {
                this.DrawBimap = null;
            }
        }
Пример #2
0
        private void Draw()
        {
            byte[] image;
            int    image_pos;

            if (ImageOption.SelectedIndex == 0 || ImageOption.SelectedIndex == 3)
            {//圧縮画像
                image = LZ77.decompress(Program.ROM.Data
                                        , U.toOffset(Image.Value));
                image_pos = 0;
                if (image.Length <= 2)
                {
                    X_BG_PIC.Image = null;
                    this.USE_PALETTE_NUMBER.Text = "1";
                    this.DrawBimap = null;
                    return;
                }
            }
            else if (ImageOption.SelectedIndex == 2)
            {//第2圧縮画像
                image = LZ77.decompress(Program.ROM.Data, U.toOffset(Image.Value));
                byte[] image2 = LZ77.decompress(Program.ROM.Data, U.toOffset(Image2.Value));
                image_pos = 0;
                if (image.Length <= 2)
                {
                    X_BG_PIC.Image = null;
                    this.USE_PALETTE_NUMBER.Text = "1";
                    this.DrawBimap = null;
                    return;
                }
                if (image2.Length > 2)
                {
                    List <byte> imageUZList = new List <byte>();
                    imageUZList.AddRange(image);
                    imageUZList.AddRange(image2);

                    image = imageUZList.ToArray();
                }
            }
            else
            {//無圧縮画像
                image     = Program.ROM.Data;
                image_pos = (int)U.toOffset(Image.Value);
            }
            byte[] palette;
            if (PaletteOption.SelectedIndex == 1)
            {//lz77 palette
                palette = LZ77.decompress(Program.ROM.Data, U.toOffset(PALETTE.Value));
                uint palette_offset = ToPaletteOffset(0, (uint)PALETTENO.Value);
                palette = U.subrange(palette, palette_offset, palette_offset + (0x20 * 16));
            }
            else
            {//通常のパレット
                uint palette_addr = ToPaletteOffset((uint)PALETTE.Value, (uint)PALETTENO.Value);
                palette = Program.ROM.getBinaryData(palette_addr, 0x20 * 16);
            }

            byte[] tsa;
            int    tsa_pos;

            if (TSAOption.SelectedIndex == 0)
            {//TSAを利用しない
                tsa     = null;
                tsa_pos = 0;

                Bitmap bitmap;
                if (ImageOption.SelectedIndex == 3)
                {///256
                    bitmap = ImageUtil.ByteToImage256Tile((int)PicWidth.Value * 8
                                                          , (int)PicHeight.Value * 8
                                                          , image
                                                          , image_pos
                                                          , palette
                                                          , 0
                                                          );
                    this.USE_PALETTE_NUMBER.Text = "16";
                }
                else
                {
                    bitmap = ImageUtil.ByteToImage16Tile((int)PicWidth.Value * 8
                                                         , (int)PicHeight.Value * 8
                                                         , image
                                                         , image_pos
                                                         , palette
                                                         , 0
                                                         , 0
                                                         );
                    this.USE_PALETTE_NUMBER.Text = ImageUtil.GetPalette16Count(bitmap).ToString();
                }
                X_BG_PIC.Image = U.Zoom(bitmap, ZoomComboBox.SelectedIndex);
                this.DrawBimap = bitmap;
            }
            else if (TSAOption.SelectedIndex == 1)
            {//圧縮TSAを利用する
                tsa     = LZ77.decompress(Program.ROM.Data, U.toOffset(TSA.Value));
                tsa_pos = 0;

                if (tsa.Length <= 2)
                {
                    X_BG_PIC.Image = ImageUtil.BlankDummy();
                    return;
                }
                Bitmap bitmap;
                if (ImageOption.SelectedIndex == 3)
                {///256
                    bitmap = ImageUtil.ByteToImage256Tile((int)PicWidth.Value * 8
                                                          , (int)PicHeight.Value * 8
                                                          , image
                                                          , image_pos
                                                          , palette
                                                          , 0
                                                          , tsa
                                                          , tsa_pos
                                                          );
                    this.USE_PALETTE_NUMBER.Text = "16";
                }
                else
                {
                    bitmap = ImageUtil.ByteToImage16Tile((int)PicWidth.Value * 8
                                                         , (int)PicHeight.Value * 8
                                                         , image
                                                         , image_pos
                                                         , palette
                                                         , 0
                                                         , tsa
                                                         , tsa_pos
                                                         , 0
                                                         );
                    this.USE_PALETTE_NUMBER.Text = ImageUtil.GetPalette16CountForTSA(tsa, (uint)tsa_pos, (uint)(PicWidth.Value * PicHeight.Value)).ToString();
                }
                X_BG_PIC.Image = U.Zoom(bitmap, ZoomComboBox.SelectedIndex);
                this.DrawBimap = bitmap;
            }
            else if (TSAOption.SelectedIndex == 2)
            {//圧縮ヘッダ付きTSAを利用する
                tsa     = LZ77.decompress(Program.ROM.Data, U.toOffset(TSA.Value));
                tsa_pos = 0;
                if (tsa.Length <= 2)
                {
                    X_BG_PIC.Image = ImageUtil.BlankDummy();
                    return;
                }

                Bitmap bitmap;
                if (ImageOption.SelectedIndex == 3)
                {///256
                    bitmap = ImageUtil.ByteToImage256TileHeaderTSA((int)PicWidth.Value * 8, (int)PicHeight.Value * 8, image, image_pos, palette, 0, tsa, tsa_pos);
                    this.USE_PALETTE_NUMBER.Text = "16";
                }
                else
                {
                    bitmap = ImageUtil.ByteToImage16TileHeaderTSA((int)PicWidth.Value * 8, (int)PicHeight.Value * 8, image, image_pos, palette, 0, tsa, tsa_pos);
                    this.USE_PALETTE_NUMBER.Text = ImageUtil.GetPalette16CountForTSA(tsa, (uint)tsa_pos + 2, (uint)(PicWidth.Value * PicHeight.Value)).ToString();
                }
                X_BG_PIC.Image = U.Zoom(bitmap, ZoomComboBox.SelectedIndex);
                this.DrawBimap = bitmap;
            }
            else if (TSAOption.SelectedIndex == 3)
            {//無圧縮ヘッダ付きTSAを利用する
                tsa     = Program.ROM.Data;
                tsa_pos = (int)U.toOffset(TSA.Value);

                Bitmap bitmap;
                if (ImageOption.SelectedIndex == 3)
                {///256
                    bitmap = ImageUtil.ByteToImage256TileHeaderTSA((int)PicWidth.Value * 8, (int)PicHeight.Value * 8, image, image_pos, palette, 0, tsa, tsa_pos);
                    this.USE_PALETTE_NUMBER.Text = "16";
                }
                else
                {
                    bitmap = ImageUtil.ByteToImage16TileHeaderTSA((int)PicWidth.Value * 8, (int)PicHeight.Value * 8, image, image_pos, palette, 0, tsa, tsa_pos);
                    this.USE_PALETTE_NUMBER.Text = ImageUtil.GetPalette16CountForTSA(tsa, (uint)tsa_pos + 2, (uint)(PicWidth.Value * PicHeight.Value)).ToString();
                }
                X_BG_PIC.Image = U.Zoom(bitmap, ZoomComboBox.SelectedIndex);
                this.DrawBimap = bitmap;
            }
            else if (TSAOption.SelectedIndex == 4)
            {//無圧縮TSAを利用する
                tsa     = Program.ROM.Data;
                tsa_pos = (int)U.toOffset(TSA.Value);

                Bitmap bitmap;
                if (ImageOption.SelectedIndex == 3)
                {///256
                    bitmap = ImageUtil.ByteToImage256Tile((int)PicWidth.Value * 8, (int)PicHeight.Value * 8, image, image_pos, palette, 0, tsa, tsa_pos);
                    this.USE_PALETTE_NUMBER.Text = "16";
                }
                else
                {
                    bitmap = ImageUtil.ByteToImage16Tile((int)PicWidth.Value * 8, (int)PicHeight.Value * 8, image, image_pos, palette, 0, tsa, tsa_pos);
                    this.USE_PALETTE_NUMBER.Text = ImageUtil.GetPalette16CountForTSA(tsa, (uint)tsa_pos, (uint)(PicWidth.Value * PicHeight.Value)).ToString();
                }
                X_BG_PIC.Image = U.Zoom(bitmap, ZoomComboBox.SelectedIndex);
                this.DrawBimap = bitmap;
            }
            else if (TSAOption.SelectedIndex == 5)
            {//パレットマップとして解釈する
                tsa     = Program.ROM.Data;
                tsa_pos = (int)U.toOffset(TSA.Value);

                Bitmap bitmap = ImageUtil.ByteToImage16TilePaletteMap((int)PicWidth.Value * 8
                                                                      , (int)PicHeight.Value * 8
                                                                      , image
                                                                      , image_pos
                                                                      , palette
                                                                      , 0
                                                                      , tsa
                                                                      , tsa_pos
                                                                      );
                X_BG_PIC.Image = U.Zoom(bitmap, ZoomComboBox.SelectedIndex);
                this.USE_PALETTE_NUMBER.Text = "4";
                this.DrawBimap = bitmap;
            }
            else
            {
                this.DrawBimap = null;
            }

            bool tsaeditorVisible = false;

            if (ImageOption.SelectedIndex != 1)
            {     //無圧縮ではない
                if (TSAOption.SelectedIndex >= 1)
                { //TSAを利用する
                    tsaeditorVisible = true;
                }
            }
            TSAEditorButton.Visible = tsaeditorVisible;
        }