else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB))
if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB))
png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length){   int intent;   png_byte buf[1];   png_debug(1, "in png_handle_sRGB\n");   if (!(png_ptr->mode & PNG_HAVE_IHDR))      png_error(png_ptr, "Missing IHDR before sRGB");   else if (png_ptr->mode & PNG_HAVE_IDAT)   {      png_warning(png_ptr, "Invalid sRGB after IDAT");      png_crc_finish(png_ptr, length);      return;   }   else if (png_ptr->mode & PNG_HAVE_PLTE)      /* Should be an error, but we can cope with it */      png_warning(png_ptr, "Out of place sRGB chunk");   else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB))   {      png_warning(png_ptr, "Duplicate sRGB chunk");      png_crc_finish(png_ptr, length);      return;   }   if (length != 1)   {      png_warning(png_ptr, "Incorrect sRGB chunk length");      png_crc_finish(png_ptr, length);      return;   }   png_crc_read(png_ptr, buf, 1);   if (png_crc_finish(png_ptr, 0))      return;   intent = buf[0];   /* check for bad intent */   if (intent >= PNG_sRGB_INTENT_LAST)   {      png_warning(png_ptr, "Unknown sRGB intent");      return;   }#if defined(PNG_READ_gAMA_SUPPORTED) && defined(PNG_READ_GAMMA_SUPPORTED)   if ((info_ptr->valid & PNG_INFO_gAMA))   {   int igamma;#ifdef PNG_FIXED_POINT_SUPPORTED      igamma=(int)info_ptr->int_gamma;#else#  ifdef PNG_FLOATING_POINT_SUPPORTED      igamma=(int)(info_ptr->gamma * 100000.);#  endif#endif      if(igamma < 45000L || igamma > 46000L)      {         png_warning(png_ptr,           "Ignoring incorrect gAMA value when sRGB is also present");#ifndef PNG_NO_CONSOLE_IO#  ifdef PNG_FIXED_POINT_SUPPORTED         fprintf(stderr,"incorrect gamma=(%d/100000)\n",(int)png_ptr->int_gamma);#  else#    ifdef PNG_FLOATING_POINT_SUPPORTED         fprintf(stderr,"incorrect gamma=%f\n",png_ptr->gamma);#    endif#  endif#endif      }   }#endif /* PNG_READ_gAMA_SUPPORTED */#ifdef PNG_READ_cHRM_SUPPORTED#ifdef PNG_FIXED_POINT_SUPPORTED   if (info_ptr->valid & PNG_INFO_cHRM)      if (abs(info_ptr->int_x_white - 31270L) > 1000 ||          abs(info_ptr->int_y_white - 32900L) > 1000 ||          abs(info_ptr->int_x_red   - 64000L) > 1000 ||          abs(info_ptr->int_y_red   - 33000L) > 1000 ||          abs(info_ptr->int_x_green - 30000L) > 1000 ||          abs(info_ptr->int_y_green - 60000L) > 1000 ||          abs(info_ptr->int_x_blue  - 15000L) > 1000 ||          abs(info_ptr->int_y_blue  -  6000L) > 1000)         {            png_warning(png_ptr,              "Ignoring incorrect cHRM value when sRGB is also present");         }#endif /* PNG_FIXED_POINT_SUPPORTED */#endif /* PNG_READ_cHRM_SUPPORTED */   png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr, intent);}