Exemplo n.º 1
0
int main() {
	struct pixmap* img = pixmap_alloc(1600, 1200);
	if (img == NULL) {
		exit(EXIT_FAILURE); // error message is printed by pixmap_alloc()
	}

	double x = 0.666;
	for (int p = 0; p < PIXMAP_COLORS*img->width*img->height; p++) {
		x = 4 * x * (1.0 - x); // random numbers from chaotic logistic map
		img->bytes[p] = 256 * x;
	}
	//pixmap_print(img);

	pixmap_write_ppm(img, "pixmap.ppm");
	pixmap_write_ppm_gz(img, "pixmap.ppm.gz");
	pixmap_write_png(img, "pixmap.png");
	pixmap_write_jpg(img, "pixmap.jpg");

	img->chroma = PIXMAP_CHROMA_422;
	img->quality = 40;
	pixmap_write_jpg(img, "pixmap_c422_q40.jpg");
	img->chroma = PIXMAP_CHROMA_411;
	img->quality = 20;
	pixmap_write_jpg(img, "pixmap_c411_q20.jpg");

	pixmap_free(img);
	return 0;
}
Exemplo n.º 2
0
Pixmap *Pixmap_NewFrom(const void *src, int width, int height, int pitch, PixelFormat fmt, PixmapError *error)
{
    Pixmap *pixmap;

    if (!(pixmap = pixmap_alloc(width, height, pitch, fmt, error))) {
        return NULL;
    }

    memcpy(pixmap->data, src, Pixmap_GetSize(pixmap));

    return pixmap;
}
Exemplo n.º 3
0
Pixmap *Pixmap_New(int width, int height, int pitch, PixelFormat fmt, PixmapError *error)
{
    Pixmap *pixmap;

    if (!(pixmap = pixmap_alloc(width, height, pitch, fmt, error))) {
        return NULL;
    }

    memset(pixmap->data, 0, Pixmap_GetSize(pixmap));

    return pixmap;
}