Hi I am having a hard time setting up my pixel pointer to an array where I can modify pixels and eventually use the create function to display back to the window.
I understand the first part in the documentation where I wrote this:
const Uint8* pixels = myImage.getPixelsPtr();
I also understand that it's going to return the values in groups of 4.
So how would I turn this into an array I can modify? Any help is greatly appreciated thanks in advance.
Exactly I am so glad you agree this is driving me crazy! I am probably missing something small, i am new to sfml.Image myImage;
if (!myImage.loadFromFile("cone_nebula/cone_nebula_001.png")){
return -1;
}
Texture texture;
Sprite sprite;
texture.loadFromImage(myImage);
vector <int> pixelValues;
x = myImage.getSize().x;
y = myImage.getSize().y;
cout << x << "," << y << endl;
for (int i = 0; i < x; i++){
for (int j = 0; j < y; j++){
const Color color = myImage.getPixel(i, j);
pixelValues.push_back((int)color.r);
cout << (int)color.r << endl;
cout << (int)color.b << endl;
cout << (int)color.g << endl;
cout <<"these are red pixels in array " << pixelValues[z++] << " " << z << endl;
}
}