Error Redefinition of 'pixels' with a different type: 'unsigned char *' vs 'ofPixels' (aka 'ofPixels_<unsigned char>')

I read a previous thread about converting this old code but I have failed to get it to work
I beleive this is the culprit

 unsigned char * pixels = img.getPixels();

ive added this as was testing different code

 ofPixels pixels = img.getPixels();

Would appreciate the correct workaround, thanks!


   
    img.loadImage("nasa-iceberg.jpg");
    ofPixels pixels = img.getPixels();
    unsigned char * pixels = img.getPixels();
    for(int i = 0; i < HEIGHT; i++){
        for(int j = 0; j < WIDTH; j++){
            values[j][i] = pixels[(int)(i*WIDTH+j)];
        }
    }

Think I solved it,

unsigned char * pixels = img.getPixels();

becomes

ofPixels = img.getPixels();

Is it that simple?

You can also do:

unsigned char * pixels = img.getPixels().getData();

Hope that helps!
Theo

1 Like