Example #1
0
void Image_flipY(Image *self)
{
	size_t y;
	size_t w = self->width;
	size_t h = self->height;
	int componentCount = self->componentCount;
	uint8_t *bytes = UArray_mutableBytes(self->byteArray);
	size_t bytesPerLine = componentCount * w;
	unsigned char *buf = io_malloc(bytesPerLine);

	for (y = 0; y < h/2; y ++)
	{
		uint8_t *a = bytes + componentCount * (y * w);
		uint8_t *b = bytes + componentCount * ((h-1-y) * w);

		memcpy(buf, a, bytesPerLine);
		memcpy(a,   b, bytesPerLine);
		memcpy(b,   buf, bytesPerLine);
	}
	
	io_free(buf);
}
Example #2
0
File: Common.c Project: cdcarter/io
void *cpalloc(const void *p, size_t size)
{
	void *n = io_malloc(size);
	if(p) memcpy(n, p, size);
	return n;
}