Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

acessing a 1D array with row/col

Name: Anonymous 2009-04-21 8:27

imagePtr[i*cols + j]
where i and j are the row/col coordinates. this isn't right, i can't remember how else to do it. i know it's something LIKE this, just not exactly what, and google isn't cooperating. do i need to use the memory locations?

Name: Anonymous 2009-04-21 10:49

, /prog/, >>10 and >>16 had it right, sorta. it turns out img_ptr actually isn't just a 1D array as i had thought, or something. anyway

image_ptr negateImage(image_ptr imagePtr, int rows, int cols, int maxval)
{
    int i,j;
    unsigned char image[rows][cols];
   
    for (i=0; i< rows; i++)
    {
        for (j=0; j< cols; j++)
        {
            image[i][j] = abs((imagePtr[i*cols + j]-maxval));;
        }
    }
   
    imagePtr=(image_ptr) image;
}

works now. or at least it doesn't crash and it obviously messes with the image, only question now is how to actually get the inversion working. i had thought what i had would work (it's for .pgm files), but it isn't. i can figure it out i'm sure, thanks again!

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List