Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Ajsgolf27

Pages: [1]
1
Graphics / Help with getpixelptr()
« on: June 10, 2014, 07:20:43 am »
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.

2
Graphics / getpixel() not assigning the RGBA value properly
« on: June 09, 2014, 09:37:47 pm »
I am trying to add the red pixel values into a vector, but when I print out the vector its empty. The color value prints correctly as the loop goes so its getting the values from the pixels. Also this is extremely slow would there be a better way to do this? I am still a student so any help would be greatly appreciated.

vector <Uint8> pixelValues;
        x = myImage.getSize().x;
        y = myImage.getSize().y;
        for (Uint8 i = 0; i < x; i++){
               
                for (Uint8 j = 0; j < y; j++){

                        const Color color = myImage.getPixel(i, j);
                        pixelValues.push_back((Uint8)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++] << endl;
                }
      

Pages: [1]