restore support for non-square XPM-based tiles (X11 & Gnome)
- change the way the tile sizes are calculated, based on the image size, so non-square tiles can once again be supported. - fix Gnome port so it can actually display non-square tiles, several height/width uses were backwards - update Install.X11 to note the number of tiles per row in the XPM image
This commit is contained in:
+29
-28
@@ -5,6 +5,9 @@
|
||||
#include "gnglyph.h"
|
||||
#include "tile2x11.h"
|
||||
|
||||
/* from tile.c */
|
||||
extern int total_tiles_used;
|
||||
|
||||
static GHackGlyphs ghack_glyphs;
|
||||
static GdkImlibImage** ghack_tiles = NULL;
|
||||
|
||||
@@ -45,38 +48,36 @@ static GdkImlibImage** ghack_tiles = NULL;
|
||||
*/
|
||||
|
||||
int
|
||||
ghack_init_glyphs( const char *xpmFile)
|
||||
ghack_init_glyphs(const char *xpmFile)
|
||||
{
|
||||
ghack_glyphs.im = gdk_imlib_load_image((char *) xpmFile);
|
||||
if ( ! ghack_glyphs.im )
|
||||
{
|
||||
g_error("Couldn't load required xpmFile!");
|
||||
return -1;
|
||||
ghack_glyphs.im = gdk_imlib_load_image((char *) xpmFile);
|
||||
if ( ! ghack_glyphs.im ) {
|
||||
g_error("Couldn't load required xpmFile!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
gdk_imlib_render(ghack_glyphs.im, ghack_glyphs.im->rgb_width,
|
||||
ghack_glyphs.im->rgb_height);
|
||||
gdk_imlib_render(ghack_glyphs.im, ghack_glyphs.im->rgb_width,
|
||||
ghack_glyphs.im->rgb_height);
|
||||
|
||||
if (ghack_glyphs.im->rgb_width % TILES_PER_ROW) {
|
||||
g_error("%s is not a multiple of %d (number of tiles/row) pixels wide",
|
||||
xpmFile, TILES_PER_ROW);
|
||||
return -1;
|
||||
}
|
||||
ghack_glyphs.width = ghack_glyphs.im->rgb_width / TILES_PER_ROW;
|
||||
ghack_glyphs.height = ghack_glyphs.width;
|
||||
ghack_glyphs.count =
|
||||
(ghack_glyphs.im->rgb_height * ghack_glyphs.im->rgb_width) /
|
||||
(ghack_glyphs.width * ghack_glyphs.height);
|
||||
if ((ghack_glyphs.im->rgb_width % TILES_PER_ROW) != 0 ||
|
||||
ghack_glyphs.im->rgb_width <= TILES_PER_ROW) {
|
||||
g_error("%s is not a multiple of %d (number of tiles/row) pixels wide",
|
||||
xpmFile, TILES_PER_ROW);
|
||||
return -1;
|
||||
}
|
||||
ghack_glyphs.count = total_tiles_used;
|
||||
if ((ghack_glyphs.count % TILES_PER_ROW) != 0) {
|
||||
ghack_glyphs.count +=
|
||||
TILES_PER_ROW - (ghack_glyphs.count % TILES_PER_ROW);
|
||||
}
|
||||
ghack_glyphs.width = ghack_glyphs.im->rgb_width / TILES_PER_ROW;
|
||||
ghack_glyphs.height =
|
||||
ghack_glyphs.im->rgb_height / (ghack_glyphs.count / TILES_PER_ROW);
|
||||
|
||||
|
||||
/* Assume the tiles are organized in rows of TILES_PER_ROW
|
||||
* Further, assume that the tiles are SQUARE
|
||||
*/
|
||||
ghack_tiles = g_new0( GdkImlibImage*, ghack_glyphs.count );
|
||||
if (ghack_tiles == NULL)
|
||||
return -1;
|
||||
else
|
||||
return 0;
|
||||
/* Assume the tiles are organized in rows of TILES_PER_ROW */
|
||||
ghack_tiles = g_new0( GdkImlibImage*, ghack_glyphs.count );
|
||||
return (ghack_tiles == NULL) ? -1 : 0;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -210,8 +211,8 @@ ghack_image_from_glyph( int glyph, gboolean force )
|
||||
src_y = (tile / TILES_PER_ROW) * ghack_glyphs.height;
|
||||
ghack_tiles[tile] = gdk_imlib_crop_and_clone_image(ghack_glyphs.im,
|
||||
src_x, src_y,
|
||||
ghack_glyphs.height,
|
||||
ghack_glyphs.width);
|
||||
ghack_glyphs.width,
|
||||
ghack_glyphs.height);
|
||||
}
|
||||
|
||||
if (ghack_tiles[tile] && (!ghack_tiles[tile]->pixmap || force))
|
||||
|
||||
+5
-6
@@ -221,8 +221,8 @@ ghack_init_map_window ( )
|
||||
gnome_canvas_image_get_type (),
|
||||
"x", (double) x,
|
||||
"y", (double) y,
|
||||
"width", (double) ghack_glyph_height(),
|
||||
"height", (double) ghack_glyph_width(),
|
||||
"width", (double) ghack_glyph_width(),
|
||||
"height", (double) ghack_glyph_height(),
|
||||
"anchor", GTK_ANCHOR_NORTH_WEST,
|
||||
NULL) );
|
||||
}
|
||||
@@ -234,8 +234,7 @@ ghack_init_map_window ( )
|
||||
g_warning("Bummer! Failed to load the pet_mark image!");
|
||||
}
|
||||
else {
|
||||
gdk_imlib_render(petmark, petmark->rgb_width,
|
||||
petmark->rgb_height);
|
||||
gdk_imlib_render(petmark, petmark->rgb_width, petmark->rgb_height);
|
||||
|
||||
/* ghack_map.overlay is an array of canvas images used to
|
||||
* overlay tile images...
|
||||
@@ -573,8 +572,8 @@ ghack_reinit_map_window ( )
|
||||
gnome_canvas_image_get_type (),
|
||||
"x", (double) x,
|
||||
"y", (double) y,
|
||||
"width", (double) ghack_glyph_height(),
|
||||
"height", (double) ghack_glyph_width(),
|
||||
"width", (double) ghack_glyph_width(),
|
||||
"height", (double) ghack_glyph_height(),
|
||||
"anchor", GTK_ANCHOR_NORTH_WEST,
|
||||
NULL) );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user