From 1a28393dabf4f4696bf433ddde52e7a25253c955 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Thu, 16 Oct 2008 16:34:15 +0000 Subject: various user interface related updates --- src/render/image.cc | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/render/image.cc') diff --git a/src/render/image.cc b/src/render/image.cc index 7ce8113..e740d56 100644 --- a/src/render/image.cc +++ b/src/render/image.cc @@ -44,6 +44,31 @@ void Image::swap_channels() } } +void Image::pad() +{ + unsigned int w = width(); + unsigned int h = height(); + + if ((w % 8) != 0) { + image_width = w + (8 - (w % 8)); + } + + if ((w % 8) != 0) { + image_height = h + (8 - (h % 8)); + } + + unsigned char *image_new = (unsigned char *) malloc(size()); + memset(image_new, 0, size()); + + for (size_t y =0; y < h; y++) { + memcpy((void *)&image_new[y * image_width * image_channels], + (void *)image_data[y * w * image_channels], (size_t) w); + } + + free(image_data); + image_data = image_new; +} + void Image::flip() { unsigned char line[image_width*image_channels]; -- cgit v1.2.3