void video_manager::create_snapshot_bitmap(device_t *screen) { // select the appropriate view in our dummy target if (m_snap_native && screen != NULL) { int view_index = machine().devicelist().indexof(SCREEN, screen->tag()); assert(view_index != -1); m_snap_target->set_view(view_index); } // get the minimum width/height and set it on the target INT32 width = m_snap_width; INT32 height = m_snap_height; if (width == 0 || height == 0) m_snap_target->compute_minimum_size(width, height); m_snap_target->set_bounds(width, height); // if we don't have a bitmap, or if it's not the right size, allocate a new one if (m_snap_bitmap == NULL || width != m_snap_bitmap->width || height != m_snap_bitmap->height) { if (m_snap_bitmap != NULL) auto_free(machine(), m_snap_bitmap); m_snap_bitmap = auto_alloc(machine(), bitmap_t(width, height, BITMAP_FORMAT_RGB32)); } // render the screen there render_primitive_list &primlist = m_snap_target->get_primitives(); primlist.acquire_lock(); rgb888_draw_primitives(primlist, m_snap_bitmap->base, width, height, m_snap_bitmap->rowpixels); primlist.release_lock(); }
static void save_frame_with(mame_file *fp, int scrnum, png_error (*write_handler)(mame_file *, mame_bitmap *)) { const render_primitive_list *primlist; INT32 width, height; int error; assert(scrnum >= 0 && scrnum < MAX_SCREENS); /* if no screens, do nothing */ if (snap_target == NULL) return; /* select the appropriate view in our dummy target */ render_target_set_view(snap_target, scrnum); /* get the minimum width/height and set it on the target */ render_target_get_minimum_size(snap_target, &width, &height); render_target_set_bounds(snap_target, width, height, 0); /* if we don't have a bitmap, or if it's not the right size, allocate a new one */ if (snap_bitmap == NULL || width != snap_bitmap->width || height != snap_bitmap->height) { if (snap_bitmap != NULL) bitmap_free(snap_bitmap); snap_bitmap = bitmap_alloc_format(width, height, BITMAP_FORMAT_RGB32); assert(snap_bitmap != NULL); } /* render the screen there */ primlist = render_target_get_primitives(snap_target); osd_lock_acquire(primlist->lock); rgb888_draw_primitives(primlist->head, snap_bitmap->base, width, height, snap_bitmap->rowpixels); osd_lock_release(primlist->lock); /* now do the actual work */ error = (*write_handler)(fp, snap_bitmap); }