- GisPluginMap *map = data->map;
- GisTile *tile = data->tile;
- gchar *path = data->path;
- g_free(data);
-
- /* Load pixbuf */
- g_debug("GisPluginMap: _load_tile_cb start");
- GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(path, NULL);
- if (!pixbuf) {
- g_warning("GisPluginMap: _load_tile - Error loading pixbuf %s", path);
- g_remove(path);
- g_free(path);
- return FALSE;
- }
- g_free(path);
-
- /* Create Texture */
- guchar *pixels = gdk_pixbuf_get_pixels(pixbuf);
- gboolean alpha = gdk_pixbuf_get_has_alpha(pixbuf);
- gint width = gdk_pixbuf_get_width(pixbuf);
- gint height = gdk_pixbuf_get_height(pixbuf);
-
- for (int i = 0; i < width*height; i++) {
- for (int j = 0; j < G_N_ELEMENTS(colormap); j++) {
- if (pixels[i*4+0] == colormap[j][0][0] &&
- pixels[i*4+1] == colormap[j][0][1] &&
- pixels[i*4+2] == colormap[j][0][2]) {
- pixels[i*4+0] = colormap[j][1][0];
- pixels[i*4+1] = colormap[j][1][1];
- pixels[i*4+2] = colormap[j][1][2];
- pixels[i*4+3] = colormap[j][1][3];
- break;
- }
- }
- }