Showing with 46 additions and 0 deletions.
  1. +16 −0 src/client/tile.cpp
  2. +30 −0 src/itemdef.cpp
16 changes: 16 additions & 0 deletions src/client/tile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <GLES/gl.h>
#endif

// BEGIN WIKI IMAGE EXTRACT
#include <string>
#include <iostream>
#include <algorithm>
// END WIKI IMAGE EXTRACT


/*
A cache from texture name to texture path
*/
Expand Down Expand Up @@ -1509,6 +1516,15 @@ bool TextureSource::generateImagePart(std::string part_of_name,
if (image) {
image->copyTo(baseimg);
image->drop();

// BEGIN WIKI IMAGE EXTRACT
dstream<<"WIKI IMAGE EXTRACT: part_of_name = '"<<part_of_name<<"'"<<std::endl;
std::string se(part_of_name);
irr::c8 filename[250];
snprintf(filename, 250, "itemcubes/%s.png", se.c_str());
driver->writeImageToFile(baseimg, filename);
// END WIKI IMAGE EXTRACT

}
}
/*
Expand Down
30 changes: 30 additions & 0 deletions src/itemdef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <GLES/gl.h>
#endif

// BEGIN WIKI IMAGE EXTRACT
#include <string>
#include <iostream>
#include <algorithm>
// END WIKI IMAGE EXTRACT

/*
ItemDefinition
*/
Expand Down Expand Up @@ -418,6 +424,30 @@ class CItemDefManager: public IWritableItemDefManager
cc->inventory_texture =
tsrc->getTexture(f.tiledef[0].name);
}

// BEGIN WIKI IMAGE EXTRACT
dstream<<"WIKI IMAGE EXTRACT: name = '"<<name<<"'"<<std::endl;
IrrlichtDevice *device = tsrc->getDevice();
video::IVideoDriver *driver = device->getVideoDriver();
if (cc->inventory_texture != NULL) {
video::IImage* wiki_image = driver->createImageFromData (
cc->inventory_texture->getColorFormat(),
cc->inventory_texture->getSize(),
cc->inventory_texture->lock(),
false //copy mem
);
cc->inventory_texture->unlock();
if(wiki_image != NULL) {
std::string se(name);
std::replace(se.begin(), se.end(), ':', '_');
irr::c8 filename[250];
snprintf(filename, 250, "itemcubes/%s.png", se.c_str());
driver->writeImageToFile(wiki_image, filename);
wiki_image->drop();
}
}
// END WIKI IMAGE EXTRACT

}

/*
Expand Down