Its basically a fairly simple code in c++ Which i working perfectly fine on MAC OS but on windows it's giving hard time as I not well aware how does windows Api is treating the code.
Code as follows (Where problem Starts) :
unsigned char*** output_data = new unsigned char** [8300];
for (int32_t i = 0; i < 8300; i++) {
output_data[i] = new unsigned char* [192];
for (int32_t j = 0; j < 192; j++) {
output_data[i][j] = new unsigned char[4];
}
}
//for each strip, except the last
for (int16_t s = 0; s < (number_strips); ++s) {
//clean the output array
for (int16_t i = 0; i < 8300; ++i) {
for (int16_t j = 0; j < 192; ++j) {
for (int16_t k = 0; k < 4; ++k) {
output_data[i][j][k] = 255;
}
}
}
for (int16_t j = 0; j < 192; ++j) {
//read in the new data for 192 rows
if (s < (number_strips - 1)) fread(input_data, 1, row_padded, iFile);
//This is what to do on the last strip, which may be unfilled
if (s == (number_strips - 1)) {
if ((j) < extra_rows) {
fread(input_data, 1, row_padded, iFile);
}
else {
for (uint32_t i = 0; i < row_padded; ++i) {
input_data[i] = static_cast<unsigned char>(whitePixel);
}
}
}
//rewrite the data to the output array, flipping the order
//note we use width instead of row_padded here to remove the row_padded bytes
for (int16_t i = kOffset; i < out_array_size; ++i) {
output_data[i][j][0] = input_data[(3 * (i - kOffset))];
output_data[i][j][1] = input_data[(3 * (i - kOffset) + 1)];
output_data[i][j][2] = input_data[(3 * (i - kOffset) + 2)];
}
//apply the CYMK mask
for (int16_t i = 0; i < (out_array_size + kOffset); ++i) {
holderR = static_cast<float>(output_data[i][j][0]);
holderG = static_cast<float>(output_data[i][j][1]);
holderB = static_cast<float>(output_data[i][j][2]);
holderR = (holderR / 255);
holderG = (holderG / 255);
holderB = (holderB / 255);
holderK = holderR;
if (holderK < holderG) holderK = holderG;
if (holderK < holderB) holderK = holderB;
holderK = 1 - holderK;
holderC = 255 * (1 - holderR - holderK) / (1 - holderK);
holderY = 255 * (1 - holderG - holderK) / (1 - holderK);
holderM = 255 * (1 - holderB - holderK) / (1 - holderK);
holderK = 255 * holderK;
output_data[i][j][0] = static_cast<unsigned char>(holderM);
output_data[i][j][1] = static_cast<unsigned char>(holderC);
output_data[i][j][2] = static_cast<unsigned char>(holderY);
output_data[i][j][3] = static_cast<unsigned char>(holderK);
}
//transpose data in the output array based on the offsets
for (int16_t i = 0; i < (out_array_size); i++) {
output_data[i][j][0] = output_data[i + kOffset][j][0];
output_data[i][j][1] = output_data[i + mOffset][j][1];
output_data[i][j][2] = output_data[i + yOffset][j][2];
output_data[i][j][3] = output_data[i + cOffset][j][3];
}
} //finish of function for each row
Compiler ignores this loop and gives following error :
Warning C6001 Using uninitialized memory '*output_data[i]'.
*Output_data[i] not initialized
*skip this loop assume s<(number_strips is false)
I have absolutely no idea how it behaves like this while in Mac it works without any hassle. Any help would be much help full :)
Aucun commentaire:
Enregistrer un commentaire