示例#1
0
int NDS_WriteBMP_15bpp(int width, int height, const u16 *data, const char *filename)
{
	u8* tmp = Convert15To24(data,width,height);
	bool ok = rbmp_save_image(filename,tmp,width,height,width*3,RBMP_SOURCE_TYPE_BGR24); 
	free(tmp);
	return ok?1:0;
}
示例#2
0
static bool screenshot_dump_direct(screenshot_task_state_t *state)
{
   struct scaler_ctx *scaler = (struct scaler_ctx*)&state->scaler;
   bool ret = false;
#ifdef HAVE_RBMP
   enum rbmp_source_type bmp_type = RBMP_SOURCE_TYPE_DONT_CARE;
   (void)bmp_type;
#endif

#if defined(HAVE_RPNG)
   if (state->bgr24)
      scaler->in_fmt   = SCALER_FMT_BGR24;
   else if (state->pixel_format_type == RETRO_PIXEL_FORMAT_XRGB8888)
      scaler->in_fmt   = SCALER_FMT_ARGB8888;
   else
      scaler->in_fmt   = SCALER_FMT_RGB565;

   video_frame_convert_to_bgr24(
         scaler,
         state->out_buffer,
         (const uint8_t*)state->frame + ((int)state->height - 1)
         * state->pitch,
         state->width, state->height,
         -state->pitch);

   scaler_ctx_gen_reset(&state->scaler);

   ret = rpng_save_image_bgr24(
         state->filename,
         state->out_buffer,
         state->width,
         state->height,
         state->width * 3
         );

   free(state->out_buffer);
#elif defined(HAVE_RBMP)
   if (state->bgr24)
      bmp_type = RBMP_SOURCE_TYPE_BGR24;
   else if (state->pixel_format_type == RETRO_PIXEL_FORMAT_XRGB8888)
      bmp_type = RBMP_SOURCE_TYPE_XRGB888;

   ret = rbmp_save_image(state->filename,
         state->frame,
         state->width,
         state->height,
         state->pitch,
         bmp_type);
#endif

   return ret;
}
示例#3
0
/* Take frame bottom-up. */
static bool screenshot_dump(
      const char *global_name_base,
      const char *folder,
      const void *frame,
      unsigned width,
      unsigned height,
      int pitch, bool bgr24)
{
   char filename[PATH_MAX_LENGTH] = {0};
   char shotname[256]             = {0};
   bool ret                       = false;
   settings_t *settings           = config_get_ptr();
#if defined(HAVE_ZLIB_DEFLATE) && defined(HAVE_RPNG)
   uint8_t *out_buffer            = NULL;
   struct scaler_ctx scaler       = {0};
#endif

   if (settings->auto_screenshot_filename)
   {
      fill_dated_filename(shotname, IMG_EXT, sizeof(shotname));
      fill_pathname_join(filename, folder, shotname, sizeof(filename));
   }
   else
   {
      snprintf(shotname, sizeof(shotname),"%s.png", path_basename(global_name_base));
      fill_pathname_join(filename, folder, shotname, sizeof(filename));
   }

#ifdef _XBOX1
   d3d_video_t *d3d = (d3d_video_t*)video_driver_get_ptr(true);
   D3DSurface *surf = NULL;

   d3d->dev->GetBackBuffer(-1, D3DBACKBUFFER_TYPE_MONO, &surf);
   if (XGWriteSurfaceToFile(surf, filename) == S_OK)
      ret = true;
   surf->Release();
#elif defined(HAVE_ZLIB_DEFLATE) && defined(HAVE_RPNG)
   out_buffer = (uint8_t*)malloc(width * height * 3);
   if (!out_buffer)
      return false;

   video_frame_convert_to_bgr24(
         &scaler,
         out_buffer,
         (const uint8_t*)frame + ((int)height - 1) * pitch,
         width, height,
         -pitch,
         bgr24);

   scaler_ctx_gen_reset(&scaler);

   ret = rpng_save_image_bgr24(
         filename,
         out_buffer,
         width,
         height,
         width * 3
         );
   free(out_buffer);
#elif defined(HAVE_RBMP)
   enum rbmp_source_type bmp_type = RBMP_SOURCE_TYPE_DONT_CARE;

   if (bgr24)
      bmp_type = RBMP_SOURCE_TYPE_BGR24;
   else if (video_driver_get_pixel_format() == RETRO_PIXEL_FORMAT_XRGB8888)
      bmp_type = RBMP_SOURCE_TYPE_XRGB888;

   ret = rbmp_save_image(filename,
         frame,
         width,
         height,
         pitch,
         bmp_type);
#endif

#ifdef HAVE_IMAGEVIEWER
   if (ret == true)
   {
      if (content_push_to_history_playlist(g_defaults.image_history, filename,  
               "imageviewer", "builtin"))
         playlist_write_file(g_defaults.image_history);
   }
#endif

   return ret;
}
示例#4
0
/**
 * task_screenshot_handler:
 * @task : the task being worked on
 *
 * Saves a screenshot to disk.
 **/
static void task_screenshot_handler(retro_task_t *task)
{
#ifdef HAVE_RBMP
   enum rbmp_source_type bmp_type = RBMP_SOURCE_TYPE_DONT_CARE;
#endif
   screenshot_task_state_t *state = (screenshot_task_state_t*)task->state;
   struct scaler_ctx *scaler      = (struct scaler_ctx*)&state->scaler;
   bool ret                       = false;

   if (task_get_progress(task) == 100)
   {
      task_set_finished(task, true);

      if (state->userbuf)
         free(state->userbuf);

      free(state);
      return;
   }
    
#ifdef HAVE_RBMP
    (void)bmp_type;
#endif

#if defined(_XBOX1)
   if (XGWriteSurfaceToFile(state->surf, state->filename) == S_OK)
      ret = true;
   state->surf->Release();
#elif defined(HAVE_RPNG)
   if (state->bgr24)
      scaler->in_fmt   = SCALER_FMT_BGR24;
   else if (state->pixel_format_type == RETRO_PIXEL_FORMAT_XRGB8888)
      scaler->in_fmt   = SCALER_FMT_ARGB8888;
   else
      scaler->in_fmt   = SCALER_FMT_RGB565;

   video_frame_convert_to_bgr24(
         scaler,
         state->out_buffer,
         (const uint8_t*)state->frame + ((int)state->height - 1) 
         * state->pitch,
         state->width, state->height,
         -state->pitch);

   scaler_ctx_gen_reset(&state->scaler);

   ret = rpng_save_image_bgr24(
         state->filename,
         state->out_buffer,
         state->width,
         state->height,
         state->width * 3
         );

   free(state->out_buffer);
#elif defined(HAVE_RBMP)
   if (state->bgr24)
      bmp_type = RBMP_SOURCE_TYPE_BGR24;
   else if (state->pixel_format_type == RETRO_PIXEL_FORMAT_XRGB8888)
      bmp_type = RBMP_SOURCE_TYPE_XRGB888;

   ret = rbmp_save_image(state->filename,
         state->frame,
         state->width,
         state->height,
         state->pitch,
         bmp_type);
#endif

#ifdef HAVE_IMAGEVIEWER
   if (ret && !state->silence)
   {
      if (
            state->history_list_enable 
            && g_defaults.image_history 
            && playlist_push(
               g_defaults.image_history,
               state->filename,
               NULL,
               "builtin",
               "imageviewer",
               NULL,
               NULL
               )
         )
         playlist_write_file(g_defaults.image_history);
   }
#endif

   task_set_progress(task, 100);

   if (!ret)
   {
      char *msg = strdup(msg_hash_to_str(MSG_FAILED_TO_TAKE_SCREENSHOT));
      runloop_msg_queue_push(msg, 1, state->is_paused ? 1 : 180, true);
      free(msg);
   }
}
示例#5
0
int NDS_WriteBMP_32bppBuffer(int width, int height, const void* buf, const char *filename)
{
	bool ok = rbmp_save_image(filename,buf,width,height,width*4,RBMP_SOURCE_TYPE_ARGB8888); 
	return ok?1:0;
}