Exemplo n.º 1
0
int		fill(t_game *filler, char *line, int fd)
{
	int		i;
	char	**tmp;

	if (!line)
		return (0);
	get_next_line(0, &line);
	free(line);
	get_next_line(0, &line);
	free(line);
	i = -1;
	while (++i < filler->coordmap[0])
	{
		get_next_line(0, &line);
		tmp = ft_strsplit(line, ' ');
//		write(fd, filler->map[i], ft_strlen(filler->map[i]));
//		write(fd, "|-|", 3);
//		write(fd, tmp[1], ft_strlen(tmp[1]));
//		write(fd, "\n", 1);
		ft_strcpy(filler->map[i], tmp[1]);
		free(tmp[0]);
		free(tmp[1]);
		free(tmp);
		free(line);
	}
	i = -1;
	while (++i < filler->coordpiece[0])
		free(filler->piece[i]);
	free(filler->piece);
	get_next_line(0, &line);
	free(filler->coordpiece);
	filler->coordpiece = coord_map(line);
	free(line);
	filler->piece = (char**)malloc(sizeof(char*) * (filler->coordpiece[0] + 1));
	i = -1;
	while (++i < filler->coordpiece[0])
		get_next_line(0, &(filler->piece[i]));
	filler->piece[filler->coordpiece[0]] = NULL;
	write(1, "5 13\n", 5);
	return (fill(filler, line, fd));
}
Exemplo n.º 2
0
void interp_bilinear(int rows, int columns, unsigned char* img,
                     int tf_rows, int tf_columns, double* coord_r, double* coord_c,
                     char mode, unsigned char cval, unsigned char *out)
{
    int tfr, tfc, y0, y1, y2, y3;
    double r,c,t,u,r_int,c_int,C;
    C = (double)cval;
    for (tfr = 0; tfr < tf_rows; tfr++) {
        for (tfc = 0; tfc < tf_columns; tfc++) {
            r = coord_r[tfr*tf_columns + tfc];
            c = coord_c[tfr*tf_columns + tfc];

            if ((mode == 'C') && ((r < 0) || (r >= rows) ||
                                  (c < 0) || (c >= columns)))
                out[tfr*tf_columns + tfc] = cval;
            else {
                r = coord_map(&rows,r,&mode);
                c = coord_map(&columns,c,&mode);

                r_int = floor(r);
                c_int = floor(c);

                t = r - r_int;
                u = c - c_int;

                y0 = img[(int)(r_int*columns + c_int)];
                y1 = img[(int)(coord_map(&rows,r_int+1,&mode)*columns + c_int)];
                y2 = img[(int)(coord_map(&rows,r_int+1,&mode)*columns +
                               coord_map(&columns,c_int+1,&mode))];
                y3 = img[(int)(r_int*columns +
                               coord_map(&columns,c_int+1,&mode))];

                out[tfr*tf_columns + tfc] =                             \
                    (1-t)*(1-u)*y0 + t*(1-u)*y1 + t*u*y2 + (1-t)*u*y3;
            }
        }
    }
}