Beispiel #1
0
        private void ExportGif(string filename)
        {
            uint mapid = this.MapPictureBox.GetMapID();

            if (mapid == U.NOT_FOUND)
            {
                return;
            }
            MapSettingForm.PLists plist = MapSettingForm.GetMapPListsWhereMapID(mapid);
            if (plist.palette_plist == 0)
            {
                return;
            }
            uint palette = MapPointerForm.PlistToOffsetAddr(MapPointerForm.PLIST_TYPE.PALETTE, plist.palette_plist);

            if (palette == U.NOT_FOUND)
            {
                return;
            }
            int palette_index = SamplePaletteComboBox.SelectedIndex;

            if (palette_index < 0)
            {
                palette_index = 0;
            }

            uint addr = InputFormRef.BaseAddress;

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

            //同じアニメを何度も出力しないように記録する.
            List <ImageUtilAnimeGif.Frame> bitmaps = new List <ImageUtilAnimeGif.Frame>();

            for (int i = 0; i < InputFormRef.DataCount; i++, addr += InputFormRef.BlockSize)
            {
                uint wait   = Program.ROM.u16(addr + 0);
                uint length = Program.ROM.u16(addr + 2);
                uint p4     = Program.ROM.p32(addr + 4);
                if (!U.isSafetyOffset(p4))
                {
                    continue;
                }

                MapSettingForm.MapAnimations anime = new MapSettingForm.MapAnimations();
                anime.change_bitmap_bytes = GetTileAnime1(p4, length);

                Bitmap mapBitmap = MapSettingForm.DrawMap(mapid, anime);
                bitmaps.Add(new ImageUtilAnimeGif.Frame(mapBitmap, wait));
            }

            //アニメgif生成
            ImageUtilAnimeGif.SaveAnimatedGif(filename, bitmaps);
            U.SelectFileByExplorer(filename);
        }
        public static void ExportGif(
            string filename      //書き込むファイル名
            , uint anime_address)
        {
            string basename = Path.GetFileNameWithoutExtension(filename) + "_";
            string basedir  = Path.GetDirectoryName(filename);

            anime_address = U.toOffset(anime_address);
            if (!U.isSafetyOffset(anime_address))
            {
                return;
            }

            //struct Frames{
            //  byte   wait;
            //  byte   00;
            //  ushort sound;
            //  void*  img;
            //  void*  pal;
            //}//sizeof()==12

            //objは圧縮されている.
            //palは、0x20(16色1パレット)固定.

            List <ImageUtilAnimeGif.Frame> bitmaps = new List <ImageUtilAnimeGif.Frame>();

            //圧縮されていないデータなので、事故防止のため リミッターをかける.
            uint limitter = anime_address + 1024 * 1024; //1MBサーチしたらもうあきらめる.

            limitter = (uint)Math.Min(limitter, Program.ROM.Data.Length);

            for (uint n = anime_address; n < limitter; n += 12)
            {
                uint wait  = Program.ROM.u8(n + 0);
                uint term1 = Program.ROM.u32(n);
                uint term2 = Program.ROM.u32(n + 4);
                if (term1 == 0 && term2 == 0)
                {
                    break;
                }

                string log;
                Bitmap bitmap = DrawFrameImage(n, out log);
                bitmaps.Add(new ImageUtilAnimeGif.Frame(bitmap, wait));
            }

            //アニメgif生成
            ImageUtilAnimeGif.SaveAnimatedGif(filename, bitmaps);
        }
        bool SaveAnimeGif(string filename, uint pic_address, int palette_type)
        {
            List<ImageUtilAnimeGif.Frame> bitmaps = new List<ImageUtilAnimeGif.Frame>();
            for (int showFrame = 0; showFrame < 0xF; showFrame++)
            {
                Bitmap bitmap = DrawMoveUnitIcon(pic_address, palette_type, showFrame);
                ImageUtil.BlackOutUnnecessaryColors(bitmap, 1);
                uint wait = 10;
                bitmaps.Add(new ImageUtilAnimeGif.Frame(bitmap, wait));
            }

            //アニメgif生成
            ImageUtilAnimeGif.SaveAnimatedGif(filename, bitmaps);
            return true;
        }
Beispiel #4
0
        public static void ExportGif(
            string filename      //書き込むファイル名
            , uint anime_address)
        {
            string basename = Path.GetFileNameWithoutExtension(filename) + "_";
            string basedir  = Path.GetDirectoryName(filename);

            anime_address = U.toOffset(anime_address);
            if (!U.isSafetyOffset(anime_address))
            {
                return;
            }

            string    programCode;
            AnimeType animeType;
            uint      anime_config_address = SkipCode(anime_address, out programCode, out animeType);

            if (anime_config_address == U.NOT_FOUND)
            {
                return;
            }
            if (anime_config_address + (4 * 5) > Program.ROM.Data.Length)
            {//範囲外
                return;
            }
            //POIN Frames
            //POIN TSAList
            //POIN GraphicsList
            //POIN PalettesList
            //WORD 0x3d1 //sound id
            uint frames      = Program.ROM.p32(anime_config_address + (4 * 0));
            uint tsalist     = Program.ROM.p32(anime_config_address + (4 * 1));
            uint graphiclist = Program.ROM.p32(anime_config_address + (4 * 2));
            uint palettelist = Program.ROM.p32(anime_config_address + (4 * 3));
            uint sound_id    = Program.ROM.u32(anime_config_address + (4 * 4));

            if (!U.isSafetyOffset(frames))
            {
                return;
            }
            if (!U.isSafetyOffset(tsalist))
            {
                return;
            }
            if (!U.isSafetyOffset(graphiclist))
            {
                return;
            }
            if (!U.isSafetyOffset(palettelist))
            {
                return;
            }

            List <ImageUtilAnimeGif.Frame> bitmaps = new List <ImageUtilAnimeGif.Frame>();

            //圧縮されていないデータなので、事故防止のため リミッターをかける.
            uint limitter = frames + 1024 * 1024; //1MBサーチしたらもうあきらめる.

            limitter = (uint)Math.Min(limitter, Program.ROM.Data.Length);

            for (uint n = frames; n < limitter; n += 4)
            {
                uint id   = Program.ROM.u16(n + 0);
                uint wait = Program.ROM.u16(n + 2);
                if (id == 0xFFFF)
                {
                    break;
                }

                Bitmap bitmap = DrawFrameImage(n, graphiclist, tsalist, palettelist);
                bitmaps.Add(new ImageUtilAnimeGif.Frame(bitmap, wait));
            }

            //アニメgif生成
            ImageUtilAnimeGif.SaveAnimatedGif(filename, bitmaps);
        }
        public static void ExportGif(
            string filename      //書き込むファイル名
            , uint frame
            , uint objRightToLeftOAM
            , uint objBGRightToLeftOAM
            )
        {
            objRightToLeftOAM   = U.toOffset(objRightToLeftOAM);
            objBGRightToLeftOAM = U.toOffset(objBGRightToLeftOAM);

            string basename = Path.GetFileNameWithoutExtension(filename) + "_";
            string basedir  = Path.GetDirectoryName(filename);

            //同じアニメを何度も出力しないように記録する.
            Dictionary <uint, Bitmap>      animeHash = new Dictionary <uint, Bitmap>();
            List <ImageUtilAnimeGif.Frame> bitmaps   = new List <ImageUtilAnimeGif.Frame>();

            frame = U.toOffset(frame);
            byte[] frameData = Program.ROM.Data;

            //圧縮されていないデータなので、事故防止のため リミッターをかける.
            uint limitter = frame + 1024 * 1024; //1MBサーチしたらもうあきらめる.

            limitter = (uint)Math.Min(limitter, Program.ROM.Data.Length);

            int termCount = 0;

            for (uint n = frame; n < limitter; n += 4)
            {
                if (frameData[n + 3] == 0x80)     //0x80 Term
                {                                 //終端.
                    termCount++;
                    if (frameData[n + 1] == 0x01) //0x00 0x01 0x00 0x80 の場合続くときがある.
                    {
                        if (termCount == 1)
                        {
                            continue;
                        }
                    }
                    break;
                }
                if (frameData[n + 3] == 0x85) //0x85 コマンド
                {
                    if (frameData[n] == 0x48)
                    {//音楽再生なのだが魔法ではS命令不可.
                    }
                    else
                    {//それ以外の 0x85命令
                    }
                    continue;
                }
                else if (frameData[n + 3] != 0x86)
                {//不明な命令なので終了
                    break;
                }

                //0x86 画像 pointer
                uint   wait      = U.u16(frameData, n);
                bool   bgExpands = IsExpandsBG(n, frame, Program.ROM.Data);
                Bitmap bitmap    = DrawFrameImage(n, frameData, objRightToLeftOAM, objBGRightToLeftOAM, bgExpands);

                bitmaps.Add(new ImageUtilAnimeGif.Frame(bitmap, wait));

                n += 24 + 4; // 24+4+4 = 32bytes
            }

            //アニメgif生成
            ImageUtilAnimeGif.SaveAnimatedGif(filename, bitmaps);
        }
Beispiel #6
0
        void ExportGif(string filename)
        {
            string basename = Path.GetFileNameWithoutExtension(filename) + "_";
            string basedir  = Path.GetDirectoryName(filename);

            List <ImageUtilAnimeGif.Frame> bitmaps = new List <ImageUtilAnimeGif.Frame>();

            if (!U.isSafetyOffset(this.FramePointer))
            {
                for (int i = 0; i < this.FramePointer; i++)
                {
                    Bitmap bitmap;
                    bitmap = DrawDirectLow(i);
                    if (bitmap == null)
                    {//デコードできなかった.
                        bitmap = ImageUtil.Blank(30 * 8, 16 * 8);
                    }

                    //利用していないパレットを消す.
                    ImageUtil.BlackOutUnnecessaryColors(bitmap, 1);

                    bitmaps.Add(new ImageUtilAnimeGif.Frame(bitmap, 1));
                }
            }
            else
            {
                //同じアニメを何度も出力しないように記録する.
                Dictionary <uint, Bitmap> animeHash = new Dictionary <uint, Bitmap>();

                uint addr = Program.ROM.p32(FramePointer);

                //圧縮されていないデータなので、事故防止のため リミッターをかける.
                uint limitter = addr + 1024 * 1024; //1MBサーチしたらもうあきらめる.
                limitter = (uint)Math.Min(limitter, Program.ROM.Data.Length);

                uint id   = 0;
                uint wait = 0;
                uint i;
                for (i = 0; addr < limitter; i++, addr += 4)
                {
                    id   = Program.ROM.u16(addr);
                    wait = Program.ROM.u16(addr + 2);

                    if (id == 0xFFFF)
                    {
                        break;
                    }

                    Bitmap bitmap;
                    string imagefilename = basename.Replace(" ", "_") + "g" + id.ToString("000") + ".png";
                    if (animeHash.ContainsKey(id))
                    {
                        bitmap = animeHash[id];
                    }
                    else
                    {
                        bitmap = DrawDirectLow((int)id);
                        if (bitmap == null)
                        {//デコードできなかった.
                            bitmap = ImageUtil.Blank(30 * 8, 16 * 8);
                        }

                        //利用していないパレットを消す.
                        ImageUtil.BlackOutUnnecessaryColors(bitmap, 1);
                        animeHash[id] = bitmap;
                    }

                    bitmaps.Add(new ImageUtilAnimeGif.Frame(bitmap, wait));
                }
            }

            //アニメgif生成
            ImageUtilAnimeGif.SaveAnimatedGif(filename, bitmaps);
        }