/***********************************************************
* Artsoft Retro-Game Library *
*----------------------------------------------------------*
-* (c) 1994-2001 Artsoft Entertainment *
+* (c) 1994-2002 Artsoft Entertainment *
* Holger Schemel *
* Detmolder Strasse 189 *
* 33604 Bielefeld *
#include "misc.h"
+/* ========================================================================= */
+/* PLATFORM SPECIFIC IMAGE FUNCTIONS */
+/* ========================================================================= */
+
#if defined(TARGET_X11)
/* for MS-DOS/Allegro, exclude all except newImage() and freeImage() */
bluestep = 256 / bluecolors;
redbottom = greenbottom = bluebottom = 0;
redtop = greentop = bluetop = 0;
+
for (a=0; a<visual->map_entries; a++)
{
if (redbottom < 256)
/* 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);
+
return NULL;
}
while ((bluebottom < 256) && (bluebottom < bluetop))
bluevalue[bluebottom++] = xcolor.pixel & visual->blue_mask;
}
+
break;
}
default:
Error(ERR_RETURN,"DirectColor, TrueColor or PseudoColor display needed");
SetError(error, "display class not supported");
+
return NULL;
}
dst_ptr += display_bytes_per_pixel;
}
}
+
break;
}
dst_ptr += display_bytes_per_pixel;
}
}
+
break;
}
default:
Error(ERR_RETURN, "RGB or TrueColor image needed");
SetError(error, "image type not supported");
+
return NULL;
}
+
break;
}
}
}
}
+
break;
}
default:
Error(ERR_RETURN,"DirectColor, TrueColor or PseudoColor display needed");
SetError(error, "display class not supported");
+
return NULL;
}
XPutImage(ximageinfo->display, ximageinfo->pixmap, gc,
ximage, 0, 0, 0, 0, ximage->width, ximage->height);
- free(ximage->data);
- ximage->data = NULL;
XDestroyImage(ximage);
- return(ximageinfo);
+ return ximageinfo;
}
void freeXImage(Image *image, XImageInfo *ximageinfo)
/* convert image structure to X11 Pixmap */
if (!(ximageinfo = Image_to_Pixmap(display, screen, visual,
window, gc, depth, image)))
+ {
+ freeImage(image);
+
return PCX_OtherError;
+ }
/* if a private colormap has been created, install it */
if (ximageinfo->cmap != DefaultColormap(display, screen))
*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;
}
#endif /* PLATFORM_UNIX */
#endif /* TARGET_X11 */
+
+
+/* ========================================================================= */
+/* PLATFORM INDEPENDANT IMAGE FUNCTIONS */
+/* ========================================================================= */
+
+struct ImageInfo
+{
+ char *source_filename;
+ int num_references;
+};
+typedef struct ImageInfo ImageInfo;
+
+static ImageInfo **ImageList = NULL;
+static struct ArtworkConfigInfo *image_config = NULL;
+static int num_images = 0;
+
+void InitImageList(struct ArtworkConfigInfo *config_list, int num_list_entries)
+{
+ if (ImageList == NULL)
+ ImageList = checked_calloc(num_list_entries * sizeof(ImageInfo *));
+
+ image_config = config_list;
+ num_images = num_list_entries;
+}