onnxruntime/test/shared_lib/fns_candy_style_transfer.c
static int read_png_file(const char* input_file, size_t* height, size_t* width, float** out, size_t* output_count) {
  png_image image; /* The control structure used by libpng */
  /* Initialize the 'png_image' structure. */
  memset(&image, 0, (sizeof image));
  image.version = PNG_IMAGE_VERSION;
  if (png_image_begin_read_from_file(&image, input_file) == 0) {
    return -1;
  }
  png_bytep buffer;
  image.format = PNG_FORMAT_BGR;
  size_t input_data_length = PNG_IMAGE_SIZE(image);
  if (input_data_length != 720 * 720 * 3) {
    printf("input_data_length:%zd\n", input_data_length);
    return -1;
  }
  buffer = (png_bytep)malloc(input_data_length);
  memset(buffer, 0, input_data_length);
  if (png_image_finish_read(&image, NULL /*background*/, buffer,
                            0 /*row_stride*/, NULL /*colormap*/) == 0) {
    return -1;
  }
  hwc_to_chw(buffer, image.height, image.width, out, output_count);
  free(buffer);
  *width = image.width;
  *height = image.height;
  return 0;
}
/**
 * \param out should be freed by caller after use
 * \param output_count Array length of the `out` param
 */
\param out should be freed by caller after use
\param output_count Array length of the `out` param
\ param out should be freed by caller after use \ param output_count Array length of the ` out ` param
static int read_png_file(const char* input_file, size_t* height, size_t* width, float** out, size_t* output_count) {
  png_image image; 
  memset(&image, 0, (sizeof image));
  image.version = PNG_IMAGE_VERSION;
  if (png_image_begin_read_from_file(&image, input_file) == 0) {
    return -1;
  }
  png_bytep buffer;
  image.format = PNG_FORMAT_BGR;
  size_t input_data_length = PNG_IMAGE_SIZE(image);
  if (input_data_length != 720 * 720 * 3) {
    printf("input_data_length:%zd\n", input_data_length);
    return -1;
  }
  buffer = (png_bytep)malloc(input_data_length);
  memset(buffer, 0, input_data_length);
  if (png_image_finish_read(&image, NULL , buffer,
                            0 , NULL ) == 0) {
    return -1;
  }
  hwc_to_chw(buffer, image.height, image.width, out, output_count);
  free(buffer);
  *width = image.width;
  *height = image.height;
  return 0;
}
static int read_png_file ( const char * input_file , size_t * height , size_t * width , float * * out , size_t * output_count ) { png_image image ; memset ( & image , 0 , ( sizeof image ) ) ; image . version = PNG_IMAGE_VERSION ; if ( png_image_begin_read_from_file ( & image , input_file ) == 0 ) { return -1 ; } png_bytep buffer ; image . format = PNG_FORMAT_BGR ; size_t input_data_length = PNG_IMAGE_SIZE ( image ) ; if ( input_data_length != 720 * 720 * 3 ) { printf ( " \n " , input_data_length ) ; return -1 ; } buffer = ( png_bytep ) malloc ( input_data_length ) ; memset ( buffer , 0 , input_data_length ) ; if ( png_image_finish_read ( & image , NULL , buffer , 0 , NULL ) == 0 ) { return -1 ; } hwc_to_chw ( buffer , image . height , image . width , out , output_count ) ; free ( buffer ) ; * width = image . width ; * height = image . height ; return 0 ; }
\param out should be freed by caller after use
 \param output_count Array length of the `out` param
\ param out should be freed by caller after use \ param output_count Array length of the ` out ` param
/* The control structure used by libpng */ /* Initialize the 'png_image' structure. */ /*background*/ /*row_stride*/ /*colormap*/