I know about *4, but I wanted to just work with the sf::Uint8 similar to sf::Color because I had arrays of sf::Color in my previous code.
Right now I am doing like you suggested, but with pointers.
I'm using pointers because GetPixelsPtr returns a pointer.
Is there a better way?
sf::Uint8* Get_Pixel(sf::Uint8* img_ptr,int w,int h,int x,int y)
{
int index=(((y*h)-y)+(x))*4;
sf::Uint8 *ptr=new sf::Uint8[3];
ptr[0]=img_ptr[index];
ptr[1]=img_ptr[index+1];
ptr[2]=img_ptr[index+2];
ptr[3]=img_ptr[index+3];
return ptr;
}
sf::Uint8 *img_ptr=const_cast<sf::Uint8*>(img.GetPixelsPtr());
sf::Uint8 *ptr3=Get_Pixel(img_ptr,w,h,80,0);