summaryrefslogtreecommitdiff
path: root/Xbit.c
diff options
context:
space:
mode:
Diffstat (limited to 'Xbit.c')
-rw-r--r--Xbit.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/Xbit.c b/Xbit.c
index 7c2322e..b4907fa 100644
--- a/Xbit.c
+++ b/Xbit.c
@@ -205,7 +205,20 @@ XImage *CreateXImage(void)
if (!use_shm)
{
- if (!(p=malloc(current->pw*current->ph*(vinfo.bits_per_rgb/8))))
+ switch(vinfo.depth)
+ {
+ case 8:
+ p=malloc(current->pw*current->ph*1);
+ break;
+ case 16:
+ p=malloc(current->pw*current->ph*2);
+ break;
+ default:
+ p=malloc(current->pw*current->ph*4);
+ break;
+ }
+
+ if (!p)
{
fprintf(stderr,"%s(%d) : FATAL:%s\n",__FILE__,__LINE__,
"Couldn't malloc() XImage data");