Exemplo n.º 1
0
void
init_ppm(struct mandelbrot_param* param)
{
	if(param->picture->data != NULL)
	{
		free(param->picture->data);
		param->picture->data = NULL;
	}

	param->picture->data = malloc(ppm_align(sizeof(color_t) * param->width, PPM_ALIGNMENT) * param->height);
	param->picture->height = param->height;
	param->picture->width = param->width;
}
Exemplo n.º 2
0
struct ppm *
ppm_alloc(int width, int height)
{
	struct ppm * picture;
	picture = malloc(sizeof(struct ppm));
	if (picture != NULL)
	{
		picture->height = height;
		picture->width = width;
		picture->data = malloc(ppm_align(sizeof(color_t) * width, PPM_ALIGNMENT) * height);
	}

	return picture;
}
Exemplo n.º 3
0
/**
 * Converts an xy coordinate to the index of an unidimensional
 * array according to the size of the picture given
 */
color_t*
coord_to_ptr(struct ppm * picture, int x, int y)
{
	return (color_t*)(((char*)picture->data) + ppm_align(picture->width * sizeof(color_t), PPM_ALIGNMENT) * y + sizeof(color_t) * x);
}