16 #ifdef PNG_WRITE_SUPPORTED
18 #ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
25 png_debug(1,
"in png_do_write_transformations");
30 #ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
32 if (png_ptr->write_user_transform_fn !=
NULL)
33 (*(png_ptr->write_user_transform_fn))
43 png_ptr->row_buf + 1);
46 #ifdef PNG_WRITE_FILLER_SUPPORTED
52 #ifdef PNG_WRITE_PACKSWAP_SUPPORTED
57 #ifdef PNG_WRITE_PACK_SUPPORTED
58 if (png_ptr->transformations &
PNG_PACK)
63 #ifdef PNG_WRITE_SWAP_SUPPORTED
68 #ifdef PNG_WRITE_SHIFT_SUPPORTED
74 #ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
79 #ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
84 #ifdef PNG_WRITE_BGR_SUPPORTED
85 if (png_ptr->transformations &
PNG_BGR)
89 #ifdef PNG_WRITE_INVERT_SUPPORTED
95 #ifdef PNG_WRITE_PACK_SUPPORTED
105 if (row_info->bit_depth == 8 &&
106 row_info->channels == 1)
108 switch ((
int)bit_depth)
122 for (i = 0; i < row_width; i++)
159 for (i = 0; i < row_width; i++)
164 v |= (value << shift);
198 for (i = 0; i < row_width; i++)
203 v |= (value << shift);
229 row_info->bit_depth = (
png_byte)bit_depth;
230 row_info->pixel_depth = (
png_byte)(bit_depth * row_info->channels);
231 row_info->rowbytes =
PNG_ROWBYTES(row_info->pixel_depth,
237 #ifdef PNG_WRITE_SHIFT_SUPPORTED
253 int shift_start[4], shift_dec[4];
258 shift_start[channels] = row_info->bit_depth - bit_depth->red;
259 shift_dec[channels] = bit_depth->red;
262 shift_start[channels] = row_info->bit_depth - bit_depth->green;
263 shift_dec[channels] = bit_depth->green;
266 shift_start[channels] = row_info->bit_depth - bit_depth->blue;
267 shift_dec[channels] = bit_depth->blue;
273 shift_start[channels] = row_info->bit_depth - bit_depth->gray;
274 shift_dec[channels] = bit_depth->gray;
280 shift_start[channels] = row_info->bit_depth - bit_depth->alpha;
281 shift_dec[channels] = bit_depth->alpha;
286 if (row_info->bit_depth < 8)
293 if (bit_depth->gray == 1 && row_info->bit_depth == 2)
296 else if (row_info->bit_depth == 4 && bit_depth->gray == 3)
302 for (i = 0; i < row_bytes; i++, bp++)
310 for (j = shift_start[0]; j > -shift_dec[0]; j -= shift_dec[0])
316 *bp |= (
png_byte)((v >> (-j)) & mask);
321 else if (row_info->bit_depth == 8)
327 for (i = 0; i < istop; i++, bp++)
332 int c = (
int)(i%channels);
337 for (j = shift_start[c]; j > -shift_dec[
c]; j -= shift_dec[
c])
343 *bp |= (
png_byte)((v >> (-j)) & 0xff);
354 for (bp = row, i = 0; i < istop; i++)
356 int c = (
int)(i%channels);
363 for (j = shift_start[c]; j > -shift_dec[
c]; j -= shift_dec[
c])
379 #ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
383 png_debug(1,
"in png_do_write_swap_alpha");
388 if (row_info->bit_depth == 8)
395 for (i = 0, sp = dp = row; i < row_width; i++)
405 #ifdef PNG_WRITE_16BIT_SUPPORTED
413 for (i = 0, sp = dp = row; i < row_width; i++)
433 if (row_info->bit_depth == 8)
440 for (i = 0, sp = dp = row; i < row_width; i++)
448 #ifdef PNG_WRITE_16BIT_SUPPORTED
456 for (i = 0, sp = dp = row; i < row_width; i++)
473 #ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
477 png_debug(1,
"in png_do_write_invert_alpha");
482 if (row_info->bit_depth == 8)
489 for (i = 0, sp = dp = row; i < row_width; i++)
497 *(dp++) = (
png_byte)(255 - *(sp++));
501 #ifdef PNG_WRITE_16BIT_SUPPORTED
509 for (i = 0, sp = dp = row; i < row_width; i++)
520 *(dp++) = (
png_byte)(255 - *(sp++));
521 *(dp++) = (
png_byte)(255 - *(sp++));
529 if (row_info->bit_depth == 8)
536 for (i = 0, sp = dp = row; i < row_width; i++)
539 *(dp++) = (
png_byte)(255 - *(sp++));
543 #ifdef PNG_WRITE_16BIT_SUPPORTED
551 for (i = 0, sp = dp = row; i < row_width; i++)
558 *(dp++) = (
png_byte)(255 - *(sp++));
559 *(dp++) = (
png_byte)(255 - *(sp++));
569 #ifdef PNG_MNG_FEATURES_SUPPORTED
574 png_debug(1,
"in png_do_write_intrapixel");
580 if (row_info->bit_depth == 8)
594 for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
596 *(rp) = (
png_byte)((*rp - *(rp + 1)) & 0xff);
597 *(rp + 2) = (
png_byte)((*(rp + 2) - *(rp + 1)) & 0xff);
601 #ifdef PNG_WRITE_16BIT_SUPPORTED
602 else if (row_info->bit_depth == 16)
616 for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
623 *(rp ) = (
png_byte)((red >> 8) & 0xff);
625 *(rp + 4) = (
png_byte)((blue >> 8) & 0xff);
626 *(rp + 5) = (
png_byte)(blue & 0xff);
void png_do_write_intrapixel(png_row_infop row_info, png_bytep row)
void png_do_packswap(png_row_infop row_info, png_bytep row)
void png_do_invert(png_row_infop row_info, png_bytep row)
void png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
#define PNG_COLOR_TYPE_RGB
#define PNG_COLOR_TYPE_GRAY_ALPHA
#define PNG_COLOR_TYPE_PALETTE
void png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
#define PNG_COLOR_TYPE_RGB_ALPHA
PNG_CONST png_color_8 FAR * png_const_color_8p
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s0
GLenum GLenum GLvoid * row
png_struct FAR * png_structp
#define PNG_COLOR_MASK_COLOR
unsigned short png_uint_16
void png_do_bgr(png_row_infop row_info, png_bytep row)
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s1
void png_do_shift(png_row_infop row_info, png_bytep row, png_const_color_8p bit_depth)
EGLSurface EGLint void ** value
#define PNG_COLOR_MASK_ALPHA
png_row_info FAR * png_row_infop
void png_do_swap(png_row_infop row_info, png_bytep row)
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
#define PNG_USER_TRANSFORM
#define PNG_FLAG_FILLER_AFTER
void png_do_write_transformations(png_structp png_ptr, png_row_infop row_info)
#define PNG_ROWBYTES(pixel_bits, width)
void png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
void png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)