// Create copy of src_img with web safe colors void webify( img *src_img, char *dst_name ) { long pixel, color, old_pixel, new_pixel, error[3] = {0,0,0} ; img *dst_img = copy_img( "hw9", src_img ) ; // With dithering for( pixel = 0 ; pixel < dst_img->size / dst_img->colors ; pixel++ ) { for( color = 0 ; color < dst_img->colors ; color++ ) { old_pixel = CAP( dst_img->image[color * dst_img->rows * dst_img->cols + pixel] + error[color] ) ; new_pixel = CAP( recolor_for_web( old_pixel )) ; error[color] = old_pixel - new_pixel ; dst_img->image[color * dst_img->rows * dst_img->cols + pixel] = new_pixel ; } } write_img( "hw9", dst_img, dst_name ) ; return ; }
Card::Card(const image* img, int _chars) : chars(_chars) { skin = copy_img(img); }