⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pngrutil.c

📁 Qt/Embedded是一个多平台的C++图形用户界面应用程序框架
💻 C
📖 第 1 页 / 共 5 页
字号:
         ignore the data in this chunk (which should be OK, since         it's considered ancillary for a RGB or RGBA image). */      if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_USE))      {         if (png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN)         {            png_chunk_error(png_ptr, "CRC error");         }         else         {            png_chunk_warning(png_ptr, "CRC error");            png_zfree(png_ptr, palette);            return;         }      }      /* Otherwise, we (optionally) emit a warning and use the chunk. */      else if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN))      {         png_chunk_warning(png_ptr, "CRC error");      }   }#endif   png_ptr->palette = palette;   png_ptr->num_palette = (png_uint_16)num;#ifdef PNG_FREE_ME_SUPPORTED   png_free_data(png_ptr, info_ptr, PNG_FREE_PLTE, 0);   png_ptr->free_me |= PNG_FREE_PLTE;#else   png_ptr->flags |= PNG_FLAG_FREE_PLTE;#endif   png_set_PLTE(png_ptr, info_ptr, palette, num);#if defined(PNG_READ_tRNS_SUPPORTED)   if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)   {      if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))      {         if (png_ptr->num_trans > (png_uint_16)num)         {            png_warning(png_ptr, "Truncating incorrect tRNS chunk length");            png_ptr->num_trans = (png_uint_16)num;         }         if (info_ptr->num_trans > (png_uint_16)num)         {            png_warning(png_ptr, "Truncating incorrect info tRNS chunk length");            info_ptr->num_trans = (png_uint_16)num;         }      }   }#endif}void /* PRIVATE */png_handle_IEND(png_structp png_ptr, png_infop info_ptr, png_uint_32 length){   png_debug(1, "in png_handle_IEND\n");   if (!(png_ptr->mode & PNG_HAVE_IHDR) || !(png_ptr->mode & PNG_HAVE_IDAT))   {      png_error(png_ptr, "No image in file");      /* to quiet compiler warnings about unused info_ptr */      if (info_ptr == NULL)         return;   }   png_ptr->mode |= (PNG_AFTER_IDAT | PNG_HAVE_IEND);   if (length != 0)   {      png_warning(png_ptr, "Incorrect IEND chunk length");   }   png_crc_finish(png_ptr, length);}#if defined(PNG_READ_gAMA_SUPPORTED)void /* PRIVATE */png_handle_gAMA(png_structp png_ptr, png_infop info_ptr, png_uint_32 length){   png_fixed_point igamma;#ifdef PNG_FLOATING_POINT_SUPPORTED   float file_gamma;#endif   png_byte buf[4];   png_debug(1, "in png_handle_gAMA\n");   if (!(png_ptr->mode & PNG_HAVE_IHDR))      png_error(png_ptr, "Missing IHDR before gAMA");   else if (png_ptr->mode & PNG_HAVE_IDAT)   {      png_warning(png_ptr, "Invalid gAMA 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 gAMA chunk");   else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)#if defined(PNG_READ_sRGB_SUPPORTED)      && !(info_ptr->valid & PNG_INFO_sRGB)#endif      )   {      png_warning(png_ptr, "Duplicate gAMA chunk");      png_crc_finish(png_ptr, length);      return;   }   if (length != 4)   {      png_warning(png_ptr, "Incorrect gAMA chunk length");      png_crc_finish(png_ptr, length);      return;   }   png_crc_read(png_ptr, buf, 4);   if (png_crc_finish(png_ptr, 0))      return;   igamma = (png_fixed_point)png_get_uint_32(buf);   /* check for zero gamma */   if (igamma == 0)      return;#if defined(PNG_READ_sRGB_SUPPORTED)   if (info_ptr->valid & PNG_INFO_sRGB)      if(igamma < 45000L || igamma > 46000L)      {         png_warning(png_ptr,           "Ignoring incorrect gAMA value when sRGB is also present");#ifndef PNG_NO_STDIO         fprintf(stderr, "gamma = (%d/100000)\n", (int)igamma);#endif         return;      }#endif /* PNG_READ_sRGB_SUPPORTED */#ifdef PNG_FLOATING_POINT_SUPPORTED   file_gamma = (float)igamma / (float)100000.0;#  ifdef PNG_READ_GAMMA_SUPPORTED     png_ptr->gamma = file_gamma;#  endif     png_set_gAMA(png_ptr, info_ptr, file_gamma);#endif#ifdef PNG_FIXED_POINT_SUPPORTED   png_set_gAMA_fixed(png_ptr, info_ptr, igamma);#endif}#endif#if defined(PNG_READ_sBIT_SUPPORTED)void /* PRIVATE */png_handle_sBIT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length){   png_size_t truelen;   png_byte buf[4];   png_debug(1, "in png_handle_sBIT\n");   buf[0] = buf[1] = buf[2] = buf[3] = 0;   if (!(png_ptr->mode & PNG_HAVE_IHDR))      png_error(png_ptr, "Missing IHDR before sBIT");   else if (png_ptr->mode & PNG_HAVE_IDAT)   {      png_warning(png_ptr, "Invalid sBIT 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 sBIT chunk");   }   else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT))   {      png_warning(png_ptr, "Duplicate sBIT chunk");      png_crc_finish(png_ptr, length);      return;   }   if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)      truelen = 3;   else      truelen = (png_size_t)png_ptr->channels;   if (length != truelen)   {      png_warning(png_ptr, "Incorrect sBIT chunk length");      png_crc_finish(png_ptr, length);      return;   }   png_crc_read(png_ptr, buf, truelen);   if (png_crc_finish(png_ptr, 0))      return;   if (png_ptr->color_type & PNG_COLOR_MASK_COLOR)   {      png_ptr->sig_bit.red = buf[0];      png_ptr->sig_bit.green = buf[1];      png_ptr->sig_bit.blue = buf[2];      png_ptr->sig_bit.alpha = buf[3];   }   else   {      png_ptr->sig_bit.gray = buf[0];      png_ptr->sig_bit.red = buf[0];      png_ptr->sig_bit.green = buf[0];      png_ptr->sig_bit.blue = buf[0];      png_ptr->sig_bit.alpha = buf[1];   }   png_set_sBIT(png_ptr, info_ptr, &(png_ptr->sig_bit));}#endif#if defined(PNG_READ_cHRM_SUPPORTED)void /* PRIVATE */png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length){   png_byte buf[4];#ifdef PNG_FLOATING_POINT_SUPPORTED   float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y;#endif   png_fixed_point int_x_white, int_y_white, int_x_red, int_y_red, int_x_green,      int_y_green, int_x_blue, int_y_blue;   png_debug(1, "in png_handle_cHRM\n");   if (!(png_ptr->mode & PNG_HAVE_IHDR))      png_error(png_ptr, "Missing IHDR before cHRM");   else if (png_ptr->mode & PNG_HAVE_IDAT)   {      png_warning(png_ptr, "Invalid cHRM 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, "Missing PLTE before cHRM");   else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)#if defined(PNG_READ_sRGB_SUPPORTED)      && !(info_ptr->valid & PNG_INFO_sRGB)#endif      )   {      png_warning(png_ptr, "Duplicate cHRM chunk");      png_crc_finish(png_ptr, length);      return;   }   if (length != 32)   {      png_warning(png_ptr, "Incorrect cHRM chunk length");      png_crc_finish(png_ptr, length);      return;   }   png_crc_read(png_ptr, buf, 4);   int_x_white = (png_fixed_point)png_get_uint_32(buf);   png_crc_read(png_ptr, buf, 4);   int_y_white = (png_fixed_point)png_get_uint_32(buf);   if (int_x_white > 80000L || int_y_white > 80000L ||      int_x_white + int_y_white > 100000L)   {      png_warning(png_ptr, "Invalid cHRM white point");      png_crc_finish(png_ptr, 24);      return;   }   png_crc_read(png_ptr, buf, 4);   int_x_red = (png_fixed_point)png_get_uint_32(buf);   png_crc_read(png_ptr, buf, 4);   int_y_red = (png_fixed_point)png_get_uint_32(buf);   if (int_x_red > 80000L || int_y_red > 80000L ||      int_x_red + int_y_red > 100000L)   {      png_warning(png_ptr, "Invalid cHRM red point");      png_crc_finish(png_ptr, 16);      return;   }   png_crc_read(png_ptr, buf, 4);   int_x_green = (png_fixed_point)png_get_uint_32(buf);   png_crc_read(png_ptr, buf, 4);   int_y_green = (png_fixed_point)png_get_uint_32(buf);   if (int_x_green > 80000L || int_y_green > 80000L ||      int_x_green + int_y_green > 100000L)   {      png_warning(png_ptr, "Invalid cHRM green point");      png_crc_finish(png_ptr, 8);      return;   }   png_crc_read(png_ptr, buf, 4);   int_x_blue = (png_fixed_point)png_get_uint_32(buf);   png_crc_read(png_ptr, buf, 4);   int_y_blue = (png_fixed_point)png_get_uint_32(buf);   if (int_x_blue > 80000L || int_y_blue > 80000L ||      int_x_blue + int_y_blue > 100000L)   {      png_warning(png_ptr, "Invalid cHRM blue point");      png_crc_finish(png_ptr, 0);      return;   }#ifdef PNG_FLOATING_POINT_SUPPORTED   white_x = (float)int_x_white / (float)100000.0;   white_y = (float)int_y_white / (float)100000.0;   red_x   = (float)int_x_red   / (float)100000.0;   red_y   = (float)int_y_red   / (float)100000.0;   green_x = (float)int_x_green / (float)100000.0;   green_y = (float)int_y_green / (float)100000.0;   blue_x  = (float)int_x_blue  / (float)100000.0;   blue_y  = (float)int_y_blue  / (float)100000.0;#endif#if defined(PNG_READ_sRGB_SUPPORTED)   if (info_ptr->valid & PNG_INFO_sRGB)      {      if (abs(int_x_white - 31270L) > 1000 ||          abs(int_y_white - 32900L) > 1000 ||          abs(  int_x_red - 64000L) > 1000 ||          abs(  int_y_red - 33000L) > 1000 ||          abs(int_x_green - 30000L) > 1000 ||          abs(int_y_green - 60000L) > 1000 ||          abs( int_x_blue - 15000L) > 1000 ||          abs( int_y_blue -  6000L) > 1000)         {            png_warning(png_ptr,              "Ignoring incorrect cHRM value when sRGB is also present");#ifndef PNG_NO_STDIO#ifdef PNG_FLOATING_POINT_SUPPORTED            fprintf(stderr,"wx=%f, wy=%f, rx=%f, ry=%f\n",               white_x, white_y, red_x, red_y);            fprintf(stderr,"gx=%f, gy=%f, bx=%f, by=%f\n",               green_x, green_y, blue_x, blue_y);#else            fprintf(stderr,"wx=%ld, wy=%ld, rx=%ld, ry=%ld\n",               int_x_white, int_y_white, int_x_red, int_y_red);            fprintf(stderr,"gx=%ld, gy=%ld, bx=%ld, by=%ld\n",               int_x_green, int_y_green, int_x_blue, int_y_blue);#endif#endif /* PNG_NO_STDIO */         }         png_crc_finish(png_ptr, 0);         return;      }#endif /* PNG_READ_sRGB_SUPPORTED */#ifdef PNG_FLOATING_POINT_SUPPORTED   png_set_cHRM(png_ptr, info_ptr,      white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y);#endif#ifdef PNG_FIXED_POINT_SUPPORTED   png_set_cHRM_fixed(png_ptr, info_ptr,      int_x_white, int_y_white, int_x_red, int_y_red, int_x_green,      int_y_green, int_x_blue, int_y_blue);#endif   if (png_crc_finish(png_ptr, 0))      return;}#endif#if defined(PNG_READ_sRGB_SUPPORTED)void /* PRIVATE */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 0 && defined(PNG_cHRM_SUPPORTED) && !defined(PNG_FIXED_POINT_SUPPORTED)/* We need to define these here because they aren't in png.h */   png_fixed_point int_x_white;   png_fixed_point int_y_white;   png_fixed_point int_x_red;   png_fixed_point int_y_red;   png_fixed_point int_x_green;   png_fixed_point int_y_green;   png_fixed_point int_x_blue;   png_fixed_point int_y_blue;#endif      if(igamma < 45000L || igamma > 46000L)      {         png_warning(png_ptr,           "Ignoring incorrect gAMA value when sRGB is also present");#ifndef PNG_NO_STDIO#  ifdef PNG_FIXED_POINT_SUPPORTED         fprintf(stderr,"incorrect gamma=(%d/100000)\n",(int)png_ptr->int_gamma);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -