mercredi 23 juin 2021

if statement being ignored, something wrong with uint8_t

the values are given by images, so

typedef struct IMAGE{
        uint8_t  rgbtBlue;
        uint8_t  rgbtGreen;
        uint8_t  rgbtRed;
}IMAGE;
IMAGE image[height][width];

in the function, I create another 2 dimensional array.

typedef struct BUFFER{
        uint8_t  rgbtBlue;
        uint8_t  rgbtGreen;
        uint8_t  rgbtRed;
    }BUFFER;
BUFFER buffer[height][width];

After calculation, I will give the values back, updating the images' values.

But I encounter a problem. For example:

int GxB, GyB;
buffer[i][j].rgbtBlue = round((double)sqrt(GxB * GxB + GyB * GyB));
if (buffer[i][j].rgbtBlue >= 255)
      buffer[i][j].rgbtBlue = 255;
printf("%d\n", buffer[i][j].rgbtBlue);

If statement is keeping being ignored, I know there must be something wrong with uint8_t because after I change rgbtBlue to integer, everything is fine, the if statement is working. I've searched online but cannot find the answer. Any tips will be appreciated

Aucun commentaire:

Enregistrer un commentaire