Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/render/image.cc')
-rw-r--r--src/render/image.cc25
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];