avatar.c
changeset 37 62e97e4f562c
parent 36 32424a111e97
child 38 1e64659fe32e
equal deleted inserted replaced
36:32424a111e97 37:62e97e4f562c
   183 
   183 
   184 	// get information
   184 	// get information
   185 	png_read_info (png_ptr, info_ptr);
   185 	png_read_info (png_ptr, info_ptr);
   186 
   186 
   187 	{ // set up transformations
   187 	{ // set up transformations
   188 		png_byte color_type = info_ptr->color_type;
   188 		png_byte color_type = png_get_color_type ( png_ptr, info_ptr );
   189 		png_byte bit_depth  = info_ptr->bit_depth;
   189 		png_byte bit_depth  = png_get_bit_depth  ( png_ptr, info_ptr );
   190 
   190 
   191 		// trying to convert anything to grayscale 8-bit without alpha channel
   191 		// trying to convert anything to grayscale 8-bit without alpha channel
   192 		if (color_type == PNG_COLOR_TYPE_PALETTE)
   192 		if (color_type == PNG_COLOR_TYPE_PALETTE)
   193 			png_set_palette_to_rgb (png_ptr);
   193 			png_set_palette_to_rgb (png_ptr);
   194 		if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)
   194 		if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)
   211 
   211 
   212 		// renew information in info structure
   212 		// renew information in info structure
   213 		png_read_update_info (png_ptr, info_ptr);
   213 		png_read_update_info (png_ptr, info_ptr);
   214 	}
   214 	}
   215 
   215 
   216 	width    = info_ptr->width;
   216 	width    = png_get_image_width  ( png_ptr, info_ptr );
   217 	height   = info_ptr->height;
   217 	height   = png_get_image_height ( png_ptr, info_ptr );
   218 	rowbytes = info_ptr->rowbytes;
   218 	rowbytes = png_get_rowbytes     ( png_ptr, info_ptr );
   219 
   219 
   220 	{ // allocate buffer for image data
   220 	{ // allocate buffer for image data
   221 		png_bytep chunk = g_malloc ((sizeof(png_bytep) + rowbytes) * height);
   221 		png_bytep chunk = g_malloc ((sizeof(png_bytep) + rowbytes) * height);
   222 		png_bytep start = chunk + sizeof(png_bytep) * height;
   222 		png_bytep start = chunk + sizeof(png_bytep) * height;
   223 		int       y;
   223 		int       y;