I have the error I mentioned in the title on this part of my code.
component_t *buffer = new component_t[3 * width*height];
component_t getRawDataPtr();
...
for (unsigned int i = 0; i < width*height * 3; i = i + 3) {
file.read((char *)cR, sizeof(char));
file.read((char *)cG, sizeof(char));
file.read((char *)cB, sizeof(char));
buffer[i] = cR / 255.0f;
buffer[i + 1] = cG / 255.0f;
buffer[i + 2] = cB / 255.0f;
}
file.close();
image->setData(buffer);
...
void Image::setData(const component_t * & data_ptr) {
if (height == 0 || width == 0 || buffer == nullptr)
return;
for (unsigned int i = 0; i < height*width * 3; i++)
buffer[i] = data_ptr[i];
}
I tried image->setData(*buffer) or image->setData(&buffer) but that didn't work either. If anyone knows how to fix this I'd appreciate it. Thanks in advance.