| 48 | */ |
| 49 | |
| 50 | int |
| 51 | ghack_init_glyphs(const char *xpmFile) |
| 52 | { |
| 53 | ghack_glyphs.im = gdk_imlib_load_image((char *) xpmFile); |
| 54 | if (!ghack_glyphs.im) { |
| 55 | g_error("Couldn't load required xpmFile!"); |
| 56 | return -1; |
| 57 | } |
| 58 | |
| 59 | gdk_imlib_render(ghack_glyphs.im, ghack_glyphs.im->rgb_width, |
| 60 | ghack_glyphs.im->rgb_height); |
| 61 | |
| 62 | if ((ghack_glyphs.im->rgb_width % TILES_PER_ROW) != 0 |
| 63 | || ghack_glyphs.im->rgb_width <= TILES_PER_ROW) { |
| 64 | g_error( |
| 65 | "%s is not a multiple of %d (number of tiles/row) pixels wide", |
| 66 | xpmFile, TILES_PER_ROW); |
| 67 | return -1; |
| 68 | } |
| 69 | ghack_glyphs.count = total_tiles_used; |
| 70 | if ((ghack_glyphs.count % TILES_PER_ROW) != 0) { |
| 71 | ghack_glyphs.count += |
| 72 | TILES_PER_ROW - (ghack_glyphs.count % TILES_PER_ROW); |
| 73 | } |
| 74 | ghack_glyphs.width = ghack_glyphs.im->rgb_width / TILES_PER_ROW; |
| 75 | ghack_glyphs.height = |
| 76 | ghack_glyphs.im->rgb_height / (ghack_glyphs.count / TILES_PER_ROW); |
| 77 | |
| 78 | /* Assume the tiles are organized in rows of TILES_PER_ROW */ |
| 79 | ghack_tiles = g_new0(GdkImlibImage *, ghack_glyphs.count); |
| 80 | return (ghack_tiles == NULL) ? -1 : 0; |
| 81 | } |
| 82 | |
| 83 | void |
| 84 | ghack_free_glyphs() |
no outgoing calls
no test coverage detected