rbSFML
rbSFML copied to clipboard
Found some issues with rbimage class in master branch
Well i know this project is kinda low, but i'll write this, just in case there is some people like me.
In rbimage class there is a method called "pixels" and "getpixel" which each of them are identical to oringal classes' getPixels(), getPixel(x, y).
48 : ourDefinition.defineMethod<14>("get_pixel", &rbImage::getPixel);
49 : ourDefinition.defineMethod<15>("pixels", &rbImage::getPixel);
At line number 48, 49 there is a error that "pixels" are binded to getPixel() not getPixel"s"() So, it needs to be changed like this.
48 : ourDefinition.defineMethod<14>("get_pixel", &rbImage::getPixel);
49 : ourDefinition.defineMethod<15>("pixels", &rbImage::getPixels); <-- here!
And i'd found another issue with this getPixels() method while using it. I've discovered that array's length returned by this method are one fourth of that it's suppose to be.
rb::Value rbImage::getPixels() const
{
std::vector<rb::Value> data;
const sf::Vector2u& imgSize = myObject.getSize();
const sf::Uint8* rawData = myObject.getPixelsPtr();
//originaly, it was like this :
//for(int index = 0, size = imgSize.x * imgSize.y; index < size; index++)
for(int index = 0, size = imgSize.x * imgSize.y * 4; index < size; index++) // needs to be change like this
{
data.push_back(rb::Value::create(rawData[index]));
}
return rb::Value::create(data);
}
Probably the maker have forgot about each pixel's RGBA value count, and that made the result of only calculating the pixel numbers.