diff options
author | Stijn Buys <ingar@osirion.org> | 2008-10-16 16:34:15 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-10-16 16:34:15 +0000 |
commit | 1a28393dabf4f4696bf433ddde52e7a25253c955 (patch) | |
tree | 4d4fa4034f30fc882a78ab6ea148a32e83b9e88c /src/render/image.cc | |
parent | 1e0df536c2fae85c317ce9c3cc17603d5f98c911 (diff) |
various user interface related updates
Diffstat (limited to 'src/render/image.cc')
-rw-r--r-- | src/render/image.cc | 25 |
1 files changed, 25 insertions, 0 deletions
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]; |