private Bitmap create_screen_image(int _screen_n, tiles_data _data, data_sets_manager.EScreenDataType _scr_type, utils.ETileViewType _view_type)
        {
#if DEF_SCREEN_DRAW_FAST
            Image block_img;
#endif
            int tile_n;
            int block_n;

            ushort tile_id;

            int tile_offs_x;
            int tile_offs_y;

            palette_group.Instance.set_palette(_data);

            Bitmap bmp = new Bitmap(platform_data.get_screen_width_pixels(), platform_data.get_screen_height_pixels(), PixelFormat.Format32bppPArgb);

            Graphics gfx = Graphics.FromImage(bmp);

            gfx.InterpolationMode = InterpolationMode.NearestNeighbor;
            gfx.PixelOffsetMode   = PixelOffsetMode.None;

            gfx.Clear(utils.CONST_COLOR_SCREEN_CLEAR);

            if (_scr_type == data_sets_manager.EScreenDataType.sdt_Tiles4x4)
            {
                for (tile_n = 0; tile_n < platform_data.get_screen_tiles_cnt(); tile_n++)
                {
                    tile_id = _data.get_screen_tile(_screen_n, tile_n);

                    tile_offs_x = (tile_n % platform_data.get_screen_tiles_width()) << 5;
                    tile_offs_y = (tile_n / platform_data.get_screen_tiles_width()) << 5;

                    for (block_n = 0; block_n < utils.CONST_BLOCK_SIZE; block_n++)
                    {
#if DEF_SCREEN_DRAW_FAST
                        block_img = m_imagelist_blocks.Images[_data.get_tile_block(tile_id, block_n)];

                        gfx.DrawImage(block_img, ((block_n % 2) << 4) + tile_offs_x, ((block_n >> 1) << 4) + tile_offs_y, block_img.Width >> 1, block_img.Height >> 1);
#else
#if DEF_ZX
                        utils.update_block_gfx(_data.get_tile_block(tile_id, block_n), _data, gfx, 8, 8, ((block_n % 2) << 4) + tile_offs_x, ((block_n >> 1) << 4) + tile_offs_y, utils.get_draw_block_flags_by_view_type(_view_type));
#else
                        utils.update_block_gfx(_data.get_tile_block(tile_id, block_n), _data, gfx, 8, 8, ((block_n % 2) << 4) + tile_offs_x, ((block_n >> 1) << 4) + tile_offs_y);
#endif
#endif
                    }
                }
            }
            else
            {
                for (tile_n = 0; tile_n < platform_data.get_screen_blocks_cnt(); tile_n++)
                {
#if DEF_SCREEN_DRAW_FAST
                    block_img = m_imagelist_blocks.Images[_data.get_screen_tile(_screen_n, tile_n)];

                    gfx.DrawImage(block_img, ((tile_n % platform_data.get_screen_blocks_width()) << 4), ((tile_n / platform_data.get_screen_blocks_width()) << 4), block_img.Width >> 1, block_img.Height >> 1);
#else
#if DEF_ZX
                    utils.update_block_gfx(_data.get_screen_tile(_screen_n, tile_n), _data, gfx, 8, 8, ((tile_n % platform_data.get_screen_blocks_width()) << 4), ((tile_n / platform_data.get_screen_blocks_width()) << 4), utils.get_draw_block_flags_by_view_type(_view_type));
#else
                    utils.update_block_gfx(_data.get_screen_tile(_screen_n, tile_n), _data, gfx, 8, 8, ((tile_n % platform_data.get_screen_blocks_width()) << 4), ((tile_n / platform_data.get_screen_blocks_width()) << 4));
#endif
#endif
                }
            }

            return(bmp);
        }
        private void tiles_to_blocks()
        {
            tiles_data data = null;

            screen_data  new_pattern = null;
            pattern_data pattern     = null;

            screen_data new_scr;

            int data_n;
            int ptrn_n;
            int scr_n;
            int tile_n;
            int block_n;
            int x_pos;
            int y_pos;

            for (data_n = 0; data_n < tiles_data_cnt; data_n++)
            {
                data = get_tiles_data(data_n);

                // convert screens
                for (scr_n = 0; scr_n < data.screen_data_cnt(); scr_n++)
                {
                    new_scr = new screen_data(EScreenDataType.sdt_Blocks2x2);

                    for (tile_n = 0; tile_n < platform_data.get_screen_tiles_cnt(); tile_n++)
                    {
                        for (block_n = 0; block_n < utils.CONST_BLOCK_SIZE; block_n++)
                        {
                            x_pos = ((tile_n % platform_data.get_screen_tiles_width()) << 1) + (block_n & 0x01);
                            y_pos = ((tile_n / platform_data.get_screen_tiles_width()) << 1) + ((block_n & 0x02) >> 1);

                            if ((y_pos < platform_data.get_screen_blocks_height()) && (x_pos < platform_data.get_screen_blocks_width()))
                            {
                                new_scr.set_tile((y_pos * platform_data.get_screen_blocks_width()) + x_pos, utils.get_ushort_from_ulong(data.tiles[data.get_screen_tile(scr_n, tile_n)], block_n));
                            }
                        }
                    }

                    data.screen_data_replace(scr_n, new_scr);
                }

                // convert tiles patterns
                foreach (string key in data.patterns_data.Keys)
                {
                    List <pattern_data> pattrn_list = data.patterns_data[key] as List <pattern_data>;

                    for (ptrn_n = 0; ptrn_n < pattrn_list.Count; ptrn_n++)
                    {
                        pattern = pattrn_list[ptrn_n];

                        new_pattern = new screen_data(pattern.width << 1, pattern.height << 1);

                        for (tile_n = 0; tile_n < pattern.data.length; tile_n++)
                        {
                            for (block_n = 0; block_n < utils.CONST_BLOCK_SIZE; block_n++)
                            {
                                new_pattern.set_tile(((((tile_n / pattern.width) << 1) + ((block_n & 0x02) >> 1)) * (pattern.width << 1)) + ((tile_n % pattern.width) << 1) + (block_n & 0x01), utils.get_ushort_from_ulong(data.tiles[pattern.data.get_tile(tile_n)], block_n));
                            }
                        }

                        pattrn_list[ptrn_n] = new pattern_data(pattern.name, new_pattern);
                        pattern.reset();
                    }
                }

                Array.Clear(data.tiles, 0, data.tiles.Length);
            }
        }