in this code I am using a custom engine with its own image and color data types. I am trying to loop through an images pixel data and adjust each pixel like a tint. My current code gives errors and won't compile
CP_Image tintImage(CP_Image image, int red, int green, int blue) {
// the color we will be tinting the image with
CP_Color colorToApplyTint = CP_Color_Create(red, green, blue, 127);
// the array of pixel data spots
int arraySize = CP_Image_GetWidth(image) * CP_Image_GetHeight(image);
// allocate the array memory
CP_Color* colorArray = malloc(arraySize * sizeof(CP_Color));
// get image pixel data and put it into the address of the color array
CP_Image_GetPixelData(image, colorArray);
// iterate through each pixel
for (int i = 0; i < arraySize; ++i) {
// if pixel is not transparent, overlay the tinted color
if (colorArray[i].a > 0) { // error
colorArray[i] = colorToApplyTint; // error
}
}
// Put the altered pixel data into a new CP_Image we will return
CP_Image img = image;
CP_Image_UpdatePixelData(img, colorArray);
// Free the array memory
free(colorArray);
// finally return the altered image
return img;
}