Problem is, I'm not sure how I'd get the size of the image - it can be of n size, I can't know the size ahead of time.
So, how would I do this?
current state of the function (mostly borrowed from http://irrlicht.sourceforge.net/forum/v ... 11#p169211 )
as is evident I just need to programmatically get the texture size and I can iterate over the pixels.
Code: Select all
void loadmap(std::string input)
{
ITexture* texture = driver->getTexture(input);
video::ECOLOR_FORMAT format = texture->getColorFormat();
if(video::ECF_A8R8G8B8 == format)
{
u8 * pixels = (u8 *)texture->lock();
u32 pitch = texture->getPitch();
for(int row = 0; row != 1; row++)
{
for int(column = 0; column != 1; column++)
{
SColor * pixel = (SColor *)(pixels + ((row * pitch) + (column * sizeof(SColor))));
(void)printf("R %d, G %d, B %d\n", pixel->getRed(), pixel->getGreen(), pixel->getBlue());
//I'll do other stuff here
}
}
}
else
{
(void)printf("Wrong color format for map %s\n", input.c_str());
}
texture->unlock();
}
also: I want to actually use the SColor of the pixel in question, but I can't figure out a good way to do that - perhaps casting to string and then doing string comparison (I'm looking for the exact hexadecimal color value - that's really just a getRed, cast to hexadecimal, getBlue, cast to hexadecimal, getGreen, cast to hexadecimal etc - then treat it as a space delimited string, such as FF 0B FC - compare to master list, decide what to do) - if this is a solid enough plan, then ignore this subheading - if it's a terrible idea, please elaborate as to why and what would be a better solution. This step does not have to be fast, it happens during level loading (levels are stored as png images in this project - this is so that content creation is very fast).