aboutsummaryrefslogtreecommitdiffstats
path: root/src/xlib.c
diff options
context:
space:
mode:
authorJohn Hawthorn <jhawthor@uvic.ca>2008-06-22 01:34:45 -0700
committerJohn Hawthorn <jhawthor@uvic.ca>2008-06-22 01:34:45 -0700
commit292cf3ee0494b14e6f82df755ae02b2f078afc35 (patch)
tree624dd892b6d44e85131a5a192eb3093ebc1e0428 /src/xlib.c
parent12fe3f62f2931f296beb130840c091542647319b (diff)
downloadmirror-meh-292cf3ee0494b14e6f82df755ae02b2f078afc35.tar.gz
mirror-meh-292cf3ee0494b14e6f82df755ae02b2f078afc35.tar.bz2
mirror-meh-292cf3ee0494b14e6f82df755ae02b2f078afc35.zip
cleanup
Diffstat (limited to 'src/xlib.c')
-rw-r--r--src/xlib.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/xlib.c b/src/xlib.c
index 7d8c027..5ba9d6b 100644
--- a/src/xlib.c
+++ b/src/xlib.c
@@ -1,6 +1,7 @@
#include <assert.h>
#include <stdio.h>
+#include <string.h>
#include <stdlib.h>
#include <X11/Xlib.h>
@@ -28,13 +29,14 @@ static unsigned int getshift(unsigned int mask){
#endif
}
-XImage *ximage(struct image *img, int width, int height) {
+XImage *ximage(struct image *img, unsigned int width, unsigned int height) {
int depth;
XImage *ximg = NULL;
Visual *vis;
unsigned int rshift, gshift, bshift;
- int i;
- int x,y;
+ unsigned int i;
+ unsigned int x,y;
+ unsigned int j = 0;
depth = DefaultDepth(display, screen);
vis = DefaultVisual(display, screen);
@@ -45,7 +47,7 @@ XImage *ximage(struct image *img, int width, int height) {
if (depth >= 24) {
unsigned int dx;
- size_t numNewBufBytes = (4 * width * height);
+ size_t numNewBufBytes = ((sizeof(u_int32_t)) * (width) * (height));
u_int32_t *newBuf = malloc(numNewBufBytes);
dx = 1024 * img->width / width;
@@ -57,7 +59,7 @@ XImage *ximage(struct image *img, int width, int height) {
g = (img->buf[(i >> 10)*3+1] << gshift) & vis->green_mask;
b = (img->buf[(i >> 10)*3+2] << bshift) & vis->blue_mask;
- newBuf[y * width + x] = r | g | b;
+ newBuf[j++] = r | g | b;
i += dx;
}
}
@@ -107,7 +109,7 @@ XImage *ximage(struct image *img, int width, int height) {
}
-void drawimage(struct image *img, int width, int height){
+void drawimage(struct image *img, unsigned int width, unsigned int height){
static struct image *lastimg = NULL;
static int lastwidth = 0, lastheight = 0;
static XImage *ximg = NULL;
@@ -151,7 +153,7 @@ void drawimage(struct image *img, int width, int height){
}
-void setaspect(int w, int h){
+void setaspect(unsigned int w, unsigned int h){
XSizeHints *hints = XAllocSizeHints();
hints->flags = PAspect;
hints->min_aspect.x = hints->max_aspect.x = w;