Example #1
0
static int cb_image_menu_wallpaper(void *data, size_t len)
{
   int retval;
   nbio_handle_t *nbio = (nbio_handle_t*)data; 

   if (!nbio || !data)
      return -1;

   if (  !nbio->image.handle->has_ihdr || 
         !nbio->image.handle->has_idat || 
         !nbio->image.handle->has_iend)
      return -1;

   retval = rpng_nbio_load_image_argb_process(nbio->image.handle,
         &nbio->image.ti.pixels, &nbio->image.ti.width, &nbio->image.ti.height);

   if (retval == IMAGE_PROCESS_ERROR || retval == IMAGE_PROCESS_ERROR_END)
      return -1;

   nbio->image.cb = &cb_image_menu_wallpaper_upload;

   nbio->image.is_blocking_on_processing         = true;
   nbio->image.is_finished_with_processing       = false;
   nbio->image.is_finished                       = false;

   return 0;
}
Example #2
0
static int rarch_main_data_image_iterate_process_transfer(nbio_handle_t *nbio)
{
   unsigned i, width, height;
   int retval = 0;

   if (!nbio)
      return -1;

   for (i = 0; i < nbio->image.processing_pos_increment; i++)
   {
      retval = rpng_nbio_load_image_argb_process(nbio->image.handle,
            &nbio->image.ti.pixels, &width, &height);

      nbio->image.ti.width  = width;
      nbio->image.ti.height = height;

      if (retval != IMAGE_PROCESS_NEXT)
         break;
   }

   nbio->image.processing_frame_count++;

   if (retval == IMAGE_PROCESS_NEXT)
      return 0;

   nbio->image.processing_final_state = retval;
   return -1;
}
static int cb_image_menu_generic(nbio_handle_t *nbio)
{
    unsigned width, height;
    int retval;
    if (!nbio)
        return -1;

    if (  !nbio->image.handle->has_ihdr ||
            !nbio->image.handle->has_idat ||
            !nbio->image.handle->has_iend)
        return -1;

    retval = rpng_nbio_load_image_argb_process(nbio->image.handle,
             &nbio->image.ti.pixels, &width, &height);

    nbio->image.ti.width  = width;
    nbio->image.ti.height = height;

    if (retval == IMAGE_PROCESS_ERROR || retval == IMAGE_PROCESS_ERROR_END)
        return -1;

    nbio->image.is_blocking_on_processing         = true;
    nbio->image.is_finished                       = false;

    return 0;
}
Example #4
0
static bool rpng_nbio_load_image_argb(const char *path, uint32_t **data,
      unsigned *width, unsigned *height)
{
   int retval;
   size_t file_len;
   bool ret = true;
   struct rpng_t *rpng = NULL;
   void *ptr = NULL;
   unsigned val = 0;
   struct nbio_t* handle = (void*)nbio_open(path, NBIO_READ);

   if (!handle)
      goto end;

   ptr  = nbio_get_ptr(handle, &file_len);

   nbio_begin_read(handle);

   while (!nbio_iterate(handle));

   ptr = nbio_get_ptr(handle, &file_len);

   if (!ptr)
   {
      ret = false;
      goto end;
   }

   rpng = (struct rpng_t*)calloc(1, sizeof(struct rpng_t));

   if (!rpng)
   {
      ret = false;
      goto end;
   }

   rpng->buff_data = (uint8_t*)ptr;

   if (!rpng->buff_data)
   {
      ret = false;
      goto end;
   }

   if (!rpng_nbio_load_image_argb_start(rpng))
   {
      ret = false;
      goto end;
   }

   while (rpng_nbio_load_image_argb_iterate(
            rpng->buff_data, rpng, &val))
   {
      rpng->buff_data += val;
   }

#if 0
   fprintf(stderr, "has_ihdr: %d\n", rpng->has_ihdr);
   fprintf(stderr, "has_idat: %d\n", rpng->has_idat);
   fprintf(stderr, "has_iend: %d\n", rpng->has_iend);
#endif

   if (!rpng->has_ihdr || !rpng->has_idat || !rpng->has_iend)
   {
      ret = false;
      goto end;
   }
   
   do
   {
      retval = rpng_nbio_load_image_argb_process(rpng, data, width, height);
   }while(retval == IMAGE_PROCESS_NEXT);

   if (retval == IMAGE_PROCESS_ERROR || retval == IMAGE_PROCESS_ERROR_END)
      ret = false;

end:
   if (handle)
      nbio_free(handle);
   if (rpng)
      rpng_nbio_load_image_free(rpng);
   rpng = NULL;
   if (!ret)
      free(*data);
   return ret;
}