[devel] Fix inconsistent whitespace and indentation.

This commit is contained in:
Glenn Randers-Pehrson 2010-03-03 09:35:31 -06:00
parent 262d0ff047
commit 3ea36758ef
2 changed files with 315 additions and 302 deletions

View File

@ -680,13 +680,16 @@ png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action,
switch(error_action)
{
case 1: png_ptr->transformations |= PNG_RGB_TO_GRAY;
case 1:
png_ptr->transformations |= PNG_RGB_TO_GRAY;
break;
case 2: png_ptr->transformations |= PNG_RGB_TO_GRAY_WARN;
case 2:
png_ptr->transformations |= PNG_RGB_TO_GRAY_WARN;
break;
case 3: png_ptr->transformations |= PNG_RGB_TO_GRAY_ERR;
case 3:
png_ptr->transformations |= PNG_RGB_TO_GRAY_ERR;
}
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
#ifdef PNG_READ_EXPAND_SUPPORTED
@ -774,7 +777,8 @@ png_init_read_transformations(png_structp png_ptr)
!(color_type & PNG_COLOR_MASK_COLOR))
{
png_ptr->mode |= PNG_BACKGROUND_IS_GRAY;
} else if ((png_ptr->transformations & PNG_BACKGROUND) &&
}
else if ((png_ptr->transformations & PNG_BACKGROUND) &&
!(png_ptr->transformations & PNG_BACKGROUND_EXPAND) &&
(png_ptr->transformations & PNG_GRAY_TO_RGB) &&
png_ptr->background.red == png_ptr->background.green &&
@ -953,7 +957,8 @@ png_init_read_transformations(png_structp png_ptr)
(double)png_ptr->background.green/255.0, gs) * 255.0
+ .5);
back.blue = (png_byte)(pow(
(double)png_ptr->background.blue/255.0, gs) * 255.0 + .5);
(double)png_ptr->background.blue/255.0, gs) * 255.0
+ .5);
}
back_1.red = (png_byte)(pow(
@ -1431,7 +1436,7 @@ png_do_read_transformations(png_structp png_ptr)
png_ptr->gamma_16_from_1, png_ptr->gamma_16_to_1,
png_ptr->gamma_shift
#endif
);
);
#endif
#ifdef PNG_READ_GAMMA_SUPPORTED
@ -1895,15 +1900,15 @@ png_do_read_swap_alpha(png_row_infop row_info, png_bytep row)
void /* PRIVATE */
png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
{
png_uint_32 row_width;
png_debug(1, "in png_do_read_invert_alpha");
{
png_uint_32 row_width = row_info->width;
row_width = row_info->width;
if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
{
/* This inverts the alpha channel in RGBA */
if (row_info->bit_depth == 8)
{
/* This inverts the alpha channel in RGBA */
png_bytep sp = row + row_info->rowbytes;
png_bytep dp = sp;
png_uint_32 i;
@ -1950,9 +1955,9 @@ png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
}
else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
{
/* This inverts the alpha channel in GA */
if (row_info->bit_depth == 8)
{
/* This inverts the alpha channel in GA */
png_bytep sp = row + row_info->rowbytes;
png_bytep dp = sp;
png_uint_32 i;
@ -1963,9 +1968,9 @@ png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
*(--dp) = *(--sp);
}
}
/* This inverts the alpha channel in GGAA */
else
{
/* This inverts the alpha channel in GGAA */
png_bytep sp = row + row_info->rowbytes;
png_bytep dp = sp;
png_uint_32 i;
@ -1983,7 +1988,6 @@ png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
}
}
}
}
}
#endif
@ -2006,9 +2010,9 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
{
if (row_info->bit_depth == 8)
{
/* This changes the data from G to GX */
if (flags & PNG_FLAG_FILLER_AFTER)
{
/* This changes the data from G to GX */
png_bytep sp = row + (png_size_t)row_width;
png_bytep dp = sp + (png_size_t)row_width;
for (i = 1; i < row_width; i++)
@ -2021,9 +2025,9 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
row_info->pixel_depth = 16;
row_info->rowbytes = row_width * 2;
}
/* This changes the data from G to XG */
else
{
/* This changes the data from G to XG */
png_bytep sp = row + (png_size_t)row_width;
png_bytep dp = sp + (png_size_t)row_width;
for (i = 0; i < row_width; i++)
@ -2038,9 +2042,9 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
}
else if (row_info->bit_depth == 16)
{
/* This changes the data from GG to GGXX */
if (flags & PNG_FLAG_FILLER_AFTER)
{
/* This changes the data from GG to GGXX */
png_bytep sp = row + (png_size_t)row_width * 2;
png_bytep dp = sp + (png_size_t)row_width * 2;
for (i = 1; i < row_width; i++)
@ -2056,9 +2060,9 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
row_info->pixel_depth = 32;
row_info->rowbytes = row_width * 4;
}
/* This changes the data from GG to XXGG */
else
{
/* This changes the data from GG to XXGG */
png_bytep sp = row + (png_size_t)row_width * 2;
png_bytep dp = sp + (png_size_t)row_width * 2;
for (i = 0; i < row_width; i++)
@ -2078,9 +2082,9 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
{
if (row_info->bit_depth == 8)
{
/* This changes the data from RGB to RGBX */
if (flags & PNG_FLAG_FILLER_AFTER)
{
/* This changes the data from RGB to RGBX */
png_bytep sp = row + (png_size_t)row_width * 3;
png_bytep dp = sp + (png_size_t)row_width;
for (i = 1; i < row_width; i++)
@ -2095,9 +2099,9 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
row_info->pixel_depth = 32;
row_info->rowbytes = row_width * 4;
}
/* This changes the data from RGB to XRGB */
else
{
/* This changes the data from RGB to XRGB */
png_bytep sp = row + (png_size_t)row_width * 3;
png_bytep dp = sp + (png_size_t)row_width;
for (i = 0; i < row_width; i++)
@ -2114,9 +2118,9 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
}
else if (row_info->bit_depth == 16)
{
/* This changes the data from RRGGBB to RRGGBBXX */
if (flags & PNG_FLAG_FILLER_AFTER)
{
/* This changes the data from RRGGBB to RRGGBBXX */
png_bytep sp = row + (png_size_t)row_width * 6;
png_bytep dp = sp + (png_size_t)row_width * 2;
for (i = 1; i < row_width; i++)
@ -2136,9 +2140,9 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
row_info->pixel_depth = 64;
row_info->rowbytes = row_width * 8;
}
/* This changes the data from RRGGBB to XXRRGGBB */
else
{
/* This changes the data from RRGGBB to XXRRGGBB */
png_bytep sp = row + (png_size_t)row_width * 6;
png_bytep dp = sp + (png_size_t)row_width * 2;
for (i = 0; i < row_width; i++)
@ -2178,6 +2182,7 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
{
if (row_info->bit_depth == 8)
{
/* This changes G to RGB */
png_bytep sp = row + (png_size_t)row_width - 1;
png_bytep dp = sp + (png_size_t)row_width * 2;
for (i = 0; i < row_width; i++)
@ -2189,6 +2194,7 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
}
else
{
/* This changes GG to RRGGBB */
png_bytep sp = row + (png_size_t)row_width * 2 - 1;
png_bytep dp = sp + (png_size_t)row_width * 4;
for (i = 0; i < row_width; i++)
@ -2206,6 +2212,7 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
{
if (row_info->bit_depth == 8)
{
/* This changes GA to RGBA */
png_bytep sp = row + (png_size_t)row_width * 2 - 1;
png_bytep dp = sp + (png_size_t)row_width * 2;
for (i = 0; i < row_width; i++)
@ -2218,6 +2225,7 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
}
else
{
/* This changes GGAA to RRGGBBAA */
png_bytep sp = row + (png_size_t)row_width * 4 - 1;
png_bytep dp = sp + (png_size_t)row_width * 4;
for (i = 0; i < row_width; i++)
@ -2340,21 +2348,21 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
{
png_uint_16 red, green, blue, w;
red = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2;
green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2;
blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2;
red = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
green = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
blue = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
if (red == green && red == blue)
w = red;
else
{
png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red&0xff) >>
png_ptr->gamma_shift][red>>8];
png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red&0xff)
>> png_ptr->gamma_shift][red>>8];
png_uint_16 green_1 =
png_ptr->gamma_16_to_1[(green&0xff) >>
png_ptr->gamma_shift][green>>8];
png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >>
png_ptr->gamma_shift][blue>>8];
png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff)
>> png_ptr->gamma_shift][blue>>8];
png_uint_16 gray16 = (png_uint_16)((rc*red_1 + gc*green_1
+ bc*blue_1)>>15);
w = png_ptr->gamma_16_from_1[(gray16&0xff) >>
@ -2375,9 +2383,9 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
{
png_uint_16 red, green, blue, gray16;
red = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2;
green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2;
blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2;
red = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
green = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
blue = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
if (red != green || red != blue)
rgb_error |= 1;
@ -2438,9 +2446,9 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
{
png_uint_16 red, green, blue, w;
red = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2;
green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2;
blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2;
red = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
green = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
blue = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
if (red == green && red == blue)
w = red;
@ -2474,9 +2482,9 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
for (i = 0; i < row_width; i++)
{
png_uint_16 red, green, blue, gray16;
red = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2;
green = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2;
blue = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2;
red = (png_uint_16)((*(sp)<<8) | *(sp + 1)); sp += 2;
green = (png_uint_16)((*(sp)<<8) | *(sp + 1)); sp += 2;
blue = (png_uint_16)((*(sp)<<8) | *(sp + 1)); sp += 2;
if (red != green || red != blue)
rgb_error |= 1;
gray16 = (png_uint_16)((rc*red + gc*green + bc*blue)>>15);
@ -2571,7 +2579,7 @@ png_do_background(png_row_infop row_info, png_bytep row,
{
png_bytep sp, dp;
png_uint_32 i;
png_uint_32 row_width=row_info->width;
png_uint_32 row_width = row_info->width;
int shift;
png_debug(1, "in png_do_background");
@ -2850,8 +2858,10 @@ png_do_background(png_row_infop row_info, png_bytep row,
for (i = 0; i < row_width; i++, sp += 6)
{
png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp + 1));
png_uint_16 g = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3));
png_uint_16 b = (png_uint_16)(((*(sp+4)) << 8) + *(sp+5));
png_uint_16 g = (png_uint_16)(((*(sp + 2)) << 8)
+ *(sp + 3));
png_uint_16 b = (png_uint_16)(((*(sp + 4)) << 8)
+ *(sp + 5));
if (r == trans_color->red && g == trans_color->green &&
b == trans_color->blue)
{
@ -2883,9 +2893,11 @@ png_do_background(png_row_infop row_info, png_bytep row,
sp = row;
for (i = 0; i < row_width; i++, sp += 6)
{
png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp+1));
png_uint_16 g = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3));
png_uint_16 b = (png_uint_16)(((*(sp+4)) << 8) + *(sp+5));
png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp + 1));
png_uint_16 g = (png_uint_16)(((*(sp + 2)) << 8)
+ *(sp + 3));
png_uint_16 b = (png_uint_16)(((*(sp + 4)) << 8)
+ *(sp + 5));
if (r == trans_color->red && g == trans_color->green &&
b == trans_color->blue)
@ -2970,7 +2982,8 @@ png_do_background(png_row_infop row_info, png_bytep row,
dp = row;
for (i = 0; i < row_width; i++, sp += 4, dp += 2)
{
png_uint_16 a = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3));
png_uint_16 a = (png_uint_16)(((*(sp + 2)) << 8)
+ *(sp + 3));
if (a == (png_uint_16)0xffff)
{
@ -3011,7 +3024,8 @@ png_do_background(png_row_infop row_info, png_bytep row,
dp = row;
for (i = 0; i < row_width; i++, sp += 4, dp += 2)
{
png_uint_16 a = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3));
png_uint_16 a = (png_uint_16)(((*(sp + 2)) << 8)
+ *(sp + 3));
if (a == (png_uint_16)0xffff)
png_memcpy(dp, sp, 2);
@ -3607,7 +3621,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
{
case 1:
{
gray = (png_uint_16)((gray&0x01)*0xff);
gray = (png_uint_16)((gray & 0x01) * 0xff);
sp = row + (png_size_t)((row_width - 1) >> 3);
dp = row + (png_size_t)row_width - 1;
shift = 7 - (int)((row_width + 7) & 0x07);
@ -3634,7 +3648,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
case 2:
{
gray = (png_uint_16)((gray&0x03)*0x55);
gray = (png_uint_16)((gray & 0x03) * 0x55);
sp = row + (png_size_t)((row_width - 1) >> 2);
dp = row + (png_size_t)row_width - 1;
shift = (int)((3 - ((row_width + 3) & 0x03)) << 1);
@ -3658,7 +3672,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
case 4:
{
gray = (png_uint_16)((gray&0x0f)*0x11);
gray = (png_uint_16)((gray & 0x0f) * 0x11);
sp = row + (png_size_t)((row_width - 1) >> 1);
dp = row + (png_size_t)row_width - 1;
shift = (int)((1 - ((row_width + 1) & 0x01)) << 2);
@ -3965,7 +3979,6 @@ png_build_gamma_table(png_structp png_ptr, png_byte bit_depth)
g) * 255.0 + .5);
}
png_ptr->gamma_from_1 = (png_bytep)png_malloc(png_ptr,
(png_uint_32)256);
@ -4172,8 +4185,8 @@ png_do_read_intrapixel(png_row_infop row_info, png_bytep row)
for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
{
*(rp) = (png_byte)((256 + *rp + *(rp+1))&0xff);
*(rp+2) = (png_byte)((256 + *(rp+2) + *(rp+1))&0xff);
*(rp) = (png_byte)((256 + *rp + *(rp + 1)) & 0xff);
*(rp+2) = (png_byte)((256 + *(rp + 2) + *(rp + 1)) & 0xff);
}
}
else if (row_info->bit_depth == 16)
@ -4198,9 +4211,9 @@ png_do_read_intrapixel(png_row_infop row_info, png_bytep row)
png_uint_32 red = (png_uint_32)((s0 + s1 + 65536L) & 0xffffL);
png_uint_32 blue = (png_uint_32)((s2 + s1 + 65536L) & 0xffffL);
*(rp ) = (png_byte)((red >> 8) & 0xff);
*(rp+1) = (png_byte)(red & 0xff);
*(rp+4) = (png_byte)((blue >> 8) & 0xff);
*(rp+5) = (png_byte)(blue & 0xff);
*(rp + 1) = (png_byte)(red & 0xff);
*(rp + 4) = (png_byte)((blue >> 8) & 0xff);
*(rp + 5) = (png_byte)(blue & 0xff);
}
}
}