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

📄 pngtrans.c

📁 神龙卡开发原代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/* swaps pixel packing order within bytes */void /* PRIVATE */png_do_packswap(png_row_infop row_info, png_bytep row){   png_debug(1, "in png_do_packswap\n");   if (#if defined(PNG_USELESS_TESTS_SUPPORTED)       row != NULL && row_info != NULL &&#endif       row_info->bit_depth < 8)   {      png_bytep rp, end, table;      end = row + row_info->rowbytes;      if (row_info->bit_depth == 1)         table = onebppswaptable;      else if (row_info->bit_depth == 2)         table = twobppswaptable;      else if (row_info->bit_depth == 4)         table = fourbppswaptable;      else         return;      for (rp = row; rp < end; rp++)         *rp = table[*rp];   }}#endif /* PNG_READ_PACKSWAP_SUPPORTED or PNG_WRITE_PACKSWAP_SUPPORTED */#if defined(PNG_WRITE_FILLER_SUPPORTED) || \    defined(PNG_READ_STRIP_ALPHA_SUPPORTED)/* remove filler or alpha byte(s) */void /* PRIVATE */png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags){   png_debug(1, "in png_do_strip_filler\n");#if defined(PNG_USELESS_TESTS_SUPPORTED)   if (row != NULL && row_info != NULL)#endif   {/*      if (row_info->color_type == PNG_COLOR_TYPE_RGB ||          row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)*/      png_bytep sp=row;      png_bytep dp=row;      png_uint_32 row_width=row_info->width;      png_uint_32 i;      if (row_info->channels == 4)      {         if (row_info->bit_depth == 8)         {            /* This converts from RGBX or RGBA to RGB */            if (flags & PNG_FLAG_FILLER_AFTER)            {               dp+=3; sp+=4;               for (i = 1; i < row_width; i++)               {                  *dp++ = *sp++;                  *dp++ = *sp++;                  *dp++ = *sp++;                  sp++;               }            }            /* This converts from XRGB or ARGB to RGB */            else            {               for (i = 0; i < row_width; i++)               {                  sp++;                  *dp++ = *sp++;                  *dp++ = *sp++;                  *dp++ = *sp++;               }            }            row_info->pixel_depth = 24;            row_info->rowbytes = row_width * 3;         }         else /* if (row_info->bit_depth == 16) */         {            if (flags & PNG_FLAG_FILLER_AFTER)            {               /* This converts from RRGGBBXX or RRGGBBAA to RRGGBB */               sp += 8; dp += 6;               for (i = 1; i < row_width; i++)               {                  /* This could be (although png_memcpy is probably slower):                  png_memcpy(dp, sp, 6);                  sp += 8;                  dp += 6;                  */                  *dp++ = *sp++;                  *dp++ = *sp++;                  *dp++ = *sp++;                  *dp++ = *sp++;                  *dp++ = *sp++;                  *dp++ = *sp++;                  sp += 2;               }            }            else            {               /* This converts from XXRRGGBB or AARRGGBB to RRGGBB */               for (i = 0; i < row_width; i++)               {                  /* This could be (although png_memcpy is probably slower):                  png_memcpy(dp, sp, 6);                  sp += 8;                  dp += 6;                  */                  sp+=2;                  *dp++ = *sp++;                  *dp++ = *sp++;                  *dp++ = *sp++;                  *dp++ = *sp++;                  *dp++ = *sp++;                  *dp++ = *sp++;               }            }            row_info->pixel_depth = 48;            row_info->rowbytes = row_width * 6;         }         row_info->channels = 3;         row_info->color_type &= ~PNG_COLOR_MASK_ALPHA;      }/*      else if (row_info->color_type == PNG_COLOR_TYPE_GRAY ||               row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)*/      else if (row_info->channels == 2)      {         if (row_info->bit_depth == 8)         {            /* This converts from GX or GA to G */            if (flags & PNG_FLAG_FILLER_AFTER)            {               for (i = 0; i < row_width; i++)               {                  *dp++ = *sp++;                  sp++;               }            }            /* This converts from XG or AG to G */            else            {               for (i = 0; i < row_width; i++)               {                  sp++;                  *dp++ = *sp++;               }            }            row_info->pixel_depth = 8;            row_info->rowbytes = row_width;         }         else /* if (row_info->bit_depth == 16) */         {            if (flags & PNG_FLAG_FILLER_AFTER)            {               /* This converts from GGXX or GGAA to GG */               sp += 4; dp += 2;               for (i = 1; i < row_width; i++)               {                  *dp++ = *sp++;                  *dp++ = *sp++;                  sp += 2;               }            }            else            {               /* This converts from XXGG or AAGG to GG */               for (i = 0; i < row_width; i++)               {                  sp += 2;                  *dp++ = *sp++;                  *dp++ = *sp++;               }            }            row_info->pixel_depth = 16;            row_info->rowbytes = row_width * 2;         }         row_info->channels = 1;         row_info->color_type &= ~PNG_COLOR_MASK_ALPHA;      }   }}#endif#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)/* swaps red and blue bytes within a pixel */void /* PRIVATE */png_do_bgr(png_row_infop row_info, png_bytep row){   png_debug(1, "in png_do_bgr\n");   if (#if defined(PNG_USELESS_TESTS_SUPPORTED)       row != NULL && row_info != NULL &&#endif       (row_info->color_type & PNG_COLOR_MASK_COLOR))   {      png_uint_32 row_width = row_info->width;      if (row_info->bit_depth == 8)      {         if (row_info->color_type == PNG_COLOR_TYPE_RGB)         {            png_bytep rp;            png_uint_32 i;            for (i = 0, rp = row; i < row_width; i++, rp += 3)            {               png_byte save = *rp;               *rp = *(rp + 2);               *(rp + 2) = save;            }         }         else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)         {            png_bytep rp;            png_uint_32 i;            for (i = 0, rp = row; i < row_width; i++, rp += 4)            {               png_byte save = *rp;               *rp = *(rp + 2);               *(rp + 2) = save;            }         }      }      else if (row_info->bit_depth == 16)      {         if (row_info->color_type == PNG_COLOR_TYPE_RGB)         {            png_bytep rp;            png_uint_32 i;            for (i = 0, rp = row; i < row_width; i++, rp += 6)            {               png_byte save = *rp;               *rp = *(rp + 4);               *(rp + 4) = save;               save = *(rp + 1);               *(rp + 1) = *(rp + 5);               *(rp + 5) = save;            }         }         else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)         {            png_bytep rp;            png_uint_32 i;            for (i = 0, rp = row; i < row_width; i++, rp += 8)            {               png_byte save = *rp;               *rp = *(rp + 4);               *(rp + 4) = save;               save = *(rp + 1);               *(rp + 1) = *(rp + 5);               *(rp + 5) = save;            }         }      }   }}#endif /* PNG_READ_BGR_SUPPORTED or PNG_WRITE_BGR_SUPPORTED */#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \    defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \    defined(PNG_LEGACY_SUPPORTED)void PNGAPIpng_set_user_transform_info(png_structp png_ptr, png_voidp   user_transform_ptr, int user_transform_depth, int user_transform_channels){   png_debug(1, "in png_set_user_transform_info\n");#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)   png_ptr->user_transform_ptr = user_transform_ptr;   png_ptr->user_transform_depth = (png_byte)user_transform_depth;   png_ptr->user_transform_channels = (png_byte)user_transform_channels;#else   if(user_transform_ptr || user_transform_depth || user_transform_channels)      png_warning(png_ptr,        "This version of libpng does not support user transform info");#endif}#endif/* This function returns a pointer to the user_transform_ptr associated with * the user transform functions.  The application should free any memory * associated with this pointer before png_write_destroy and png_read_destroy * are called. */png_voidp PNGAPIpng_get_user_transform_ptr(png_structp png_ptr){#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)   return ((png_voidp)png_ptr->user_transform_ptr);#else   if(png_ptr)     return (NULL);   return (NULL);#endif}

⌨️ 快捷键说明

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