Seems like video::SColor doesn't have any getData member function. Refactored or just removed? I understood your logic, I'll try that without getData..
@@ EDIT @@
Well, I think I got it working now... thanks, I was doing the exact same thing as you did, but my math failed failed when getting the correct buffer position
Here's the code working... Both Code Block 1/2 works fine...
Code: Select all
irr::video::SColor Almirante::HtmlWindow::getPixelColor( int x, int y )
{
SColor pixel = SColor(0, 0, 0, 0);
if (!this->_texture)
return pixel;
if (x < 0 || y < 0)
return pixel;
if ( x >= this->_width || y >= this->_height)
return pixel;
///
/// Code Block 1
///
// auto video = IrrlichtManager::instance()->getVideoDriver();
// auto image = video->createImage(this->_texture, vector2d<s32>(0, 0), this->_texture->getOriginalSize());
// pixel = image->getPixel(x, y);
// image->drop();
// return pixel;
///
/// Code Bock 2
///
auto pitch = this->_texture->getPitch();
auto format = this->_texture->getColorFormat();
auto bytes = video::IImage::getBitsPerPixelFromFormat(format) / 8;
unsigned char* buffer = (unsigned char*) this->_texture->lock();
if (buffer)
{
pixel = SColor(*(unsigned int*)(buffer + (y * pitch) + (x * bytes)));
this->_texture->unlock();
}
return pixel;
}
But I have another question: does it has any difference at all (block 1 / block 2)? I mean... when creating an IImage from the texture, it does a copy of the texture buffer or just uses a pointer to the original buffer?
I'll be using block 2 anyways...
