projects
/
rocksndiamonds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
rnd-20020531-1-src
[rocksndiamonds.git]
/
src
/
libgame
/
image.c
diff --git
a/src/libgame/image.c
b/src/libgame/image.c
index ef2898e25b258478bca80bf61a6f595480931d8e..62b8fed355c5cd9bbf7931c3f53bcb5d0bd9b7fa 100644
(file)
--- a/
src/libgame/image.c
+++ b/
src/libgame/image.c
@@
-175,9
+175,13
@@
XImageInfo *Image_to_Pixmap(Display *display, int screen, Visual *visual,
XImage *ximage;
XImageInfo *ximageinfo;
byte *src_ptr, *dst_ptr;
XImage *ximage;
XImageInfo *ximageinfo;
byte *src_ptr, *dst_ptr;
+ char *error = "Image_to_Pixmap(): %s";
if (image->type == IMAGETYPE_TRUECOLOR && depth == 8)
if (image->type == IMAGETYPE_TRUECOLOR && depth == 8)
- Error(ERR_EXIT, "cannot handle true-color images on 8-bit display");
+ {
+ SetError(error, "cannot handle true-color images on 8-bit display");
+ return NULL;
+ }
if (!global_cmap)
{
if (!global_cmap)
{
@@
-241,6
+245,7
@@
XImageInfo *Image_to_Pixmap(Display *display, int screen, Visual *visual,
bluestep = 256 / bluecolors;
redbottom = greenbottom = bluebottom = 0;
redtop = greentop = bluetop = 0;
bluestep = 256 / bluecolors;
redbottom = greenbottom = bluebottom = 0;
redtop = greentop = bluetop = 0;
+
for (a=0; a<visual->map_entries; a++)
{
if (redbottom < 256)
for (a=0; a<visual->map_entries; a++)
{
if (redbottom < 256)
@@
-271,10
+276,12
@@
XImageInfo *Image_to_Pixmap(Display *display, int screen, Visual *visual,
/* something completely unexpected happened */
fprintf(stderr, "Image_to_Pixmap: XAllocColor failed on a TrueColor/Directcolor visual\n");
/* something completely unexpected happened */
fprintf(stderr, "Image_to_Pixmap: XAllocColor failed on a TrueColor/Directcolor visual\n");
+
free(redvalue);
free(greenvalue);
free(bluevalue);
free(ximageinfo);
free(redvalue);
free(greenvalue);
free(bluevalue);
free(ximageinfo);
+
return NULL;
}
return NULL;
}
@@
-287,6
+294,7
@@
XImageInfo *Image_to_Pixmap(Display *display, int screen, Visual *visual,
while ((bluebottom < 256) && (bluebottom < bluetop))
bluevalue[bluebottom++] = xcolor.pixel & visual->blue_mask;
}
while ((bluebottom < 256) && (bluebottom < bluetop))
bluevalue[bluebottom++] = xcolor.pixel & visual->blue_mask;
}
+
break;
}
break;
}
@@
-392,7
+400,10
@@
XImageInfo *Image_to_Pixmap(Display *display, int screen, Visual *visual,
}
if (!color_found) /* no more free color cells */
}
if (!color_found) /* no more free color cells */
- Error(ERR_EXIT, "cannot allocate enough color cells");
+ {
+ SetError(error, "cannot allocate enough color cells");
+ return NULL;
+ }
xcolor.pixel = xcolor2.pixel;
xcolor_private[xcolor.pixel] = xcolor;
xcolor.pixel = xcolor2.pixel;
xcolor_private[xcolor.pixel] = xcolor;
@@
-412,9
+423,10
@@
XImageInfo *Image_to_Pixmap(Display *display, int screen, Visual *visual,
break;
default:
break;
default:
- Error(ERR_RETURN, "display class not supported");
- Error(ERR_EXIT, "DirectColor, TrueColor or PseudoColor display needed");
- break;
+ Error(ERR_RETURN,"DirectColor, TrueColor or PseudoColor display needed");
+ SetError(error, "display class not supported");
+
+ return NULL;
}
#if DEBUG_TIMING
}
#if DEBUG_TIMING
@@
-460,6
+472,7
@@
XImageInfo *Image_to_Pixmap(Display *display, int screen, Visual *visual,
dst_ptr += display_bytes_per_pixel;
}
}
dst_ptr += display_bytes_per_pixel;
}
}
+
break;
}
break;
}
@@
-479,14
+492,17
@@
XImageInfo *Image_to_Pixmap(Display *display, int screen, Visual *visual,
dst_ptr += display_bytes_per_pixel;
}
}
dst_ptr += display_bytes_per_pixel;
}
}
+
break;
}
default:
break;
}
default:
- Error(ERR_RETURN, "image type not supported");
- Error(ERR_EXIT, "RGB or TrueColor image needed");
- break;
+ Error(ERR_RETURN, "RGB or TrueColor image needed");
+ SetError(error, "image type not supported");
+
+ return NULL;
}
}
+
break;
}
break;
}
@@
-510,13
+526,15
@@
XImageInfo *Image_to_Pixmap(Display *display, int screen, Visual *visual,
}
}
}
}
}
}
+
break;
}
default:
break;
}
default:
- Error(ERR_RETURN, "display class not supported");
- Error(ERR_EXIT, "DirectColor, TrueColor or PseudoColor display needed");
- break;
+ Error(ERR_RETURN,"DirectColor, TrueColor or PseudoColor display needed");
+ SetError(error, "display class not supported");
+
+ return NULL;
}
if (redvalue)
}
if (redvalue)
@@
-537,11
+555,9
@@
XImageInfo *Image_to_Pixmap(Display *display, int screen, Visual *visual,
XPutImage(ximageinfo->display, ximageinfo->pixmap, gc,
ximage, 0, 0, 0, 0, ximage->width, ximage->height);
XPutImage(ximageinfo->display, ximageinfo->pixmap, gc,
ximage, 0, 0, 0, 0, ximage->width, ximage->height);
- free(ximage->data);
- ximage->data = NULL;
XDestroyImage(ximage);
XDestroyImage(ximage);
- return
(ximageinfo)
;
+ return
ximageinfo
;
}
void freeXImage(Image *image, XImageInfo *ximageinfo)
}
void freeXImage(Image *image, XImageInfo *ximageinfo)
@@
-586,7
+602,11
@@
int Read_PCX_to_Pixmap(Display *display, Window window, GC gc, char *filename,
/* convert image structure to X11 Pixmap */
if (!(ximageinfo = Image_to_Pixmap(display, screen, visual,
window, gc, depth, image)))
/* convert image structure to X11 Pixmap */
if (!(ximageinfo = Image_to_Pixmap(display, screen, visual,
window, gc, depth, image)))
- Error(ERR_EXIT, "cannot convert Image to Pixmap");
+ {
+ freeImage(image);
+
+ return PCX_OtherError;
+ }
/* if a private colormap has been created, install it */
if (ximageinfo->cmap != DefaultColormap(display, screen))
/* if a private colormap has been created, install it */
if (ximageinfo->cmap != DefaultColormap(display, screen))
@@
-606,6
+626,10
@@
int Read_PCX_to_Pixmap(Display *display, Window window, GC gc, char *filename,
*pixmap = ximageinfo->pixmap;
*pixmap_mask = ximageinfo->pixmap_mask;
*pixmap = ximageinfo->pixmap;
*pixmap_mask = ximageinfo->pixmap_mask;
+ /* free generic image and ximageinfo after native Pixmap has been created */
+ free(ximageinfo);
+ freeImage(image);
+
return PCX_Success;
}
return PCX_Success;
}