diff options
Diffstat (limited to 'Software/Visual_Studio/Native')
3 files changed, 190 insertions, 156 deletions
diff --git a/Software/Visual_Studio/Native/Tango.ColorLib/ColorConverter.cpp b/Software/Visual_Studio/Native/Tango.ColorLib/ColorConverter.cpp index ed95ef95b..29368b743 100644 --- a/Software/Visual_Studio/Native/Tango.ColorLib/ColorConverter.cpp +++ b/Software/Visual_Studio/Native/Tango.ColorLib/ColorConverter.cpp @@ -78,7 +78,7 @@ Tango::ColorLib::ColorConverter::~ColorConverter() } } -void Tango::ColorLib::ColorConverter::ProcessHiveNeighbors(VectorXd Lab, VectorXd RGB, VectorXd Volume, int InGamutRegion, +void Tango::ColorLib::ColorConverter::ProcessHiveNeighbors(VectorXd Lab, VectorXd RGB, VectorXd Volume, int InGamutRegion, MatrixXd &ORGBHive, MatrixXd &OVolumeHive, int nHive, int *&OGamutRegion, int *indDataMax) { size_t retVal = 0; @@ -115,22 +115,22 @@ void Tango::ColorLib::ColorConverter::ProcessHiveNeighbors(VectorXd Lab, VectorX Jab1(j1, 1) = Jab(1) + dC2*cos(hue + i*dH12); Jab1(j1, 2) = Jab(2) + dC2*sin(hue + i*dH12); } -/* for (int i = 0; i < 2; ++i) - { - j1 = i + 18; - Jab1(j1, 0) = Jab(0) + (i + 1)*dL; - Jab1(j1, 1) = Jab(1); - Jab1(j1, 2) = Jab(2); - } - for (int i = 0; i < 2; ++i) - { - j1 = i + 20; - Jab1(j1, 0) = Jab(0) - (i + 1)*dL; - Jab1(j1, 1) = Jab(1); - Jab1(j1, 2) = Jab(2); - }*/ + /* for (int i = 0; i < 2; ++i) + { + j1 = i + 18; + Jab1(j1, 0) = Jab(0) + (i + 1)*dL; + Jab1(j1, 1) = Jab(1); + Jab1(j1, 2) = Jab(2); + } + for (int i = 0; i < 2; ++i) + { + j1 = i + 20; + Jab1(j1, 0) = Jab(0) - (i + 1)*dL; + Jab1(j1, 1) = Jab(1); + Jab1(j1, 2) = Jab(2); + }*/ - //convert back to CIELab + //convert back to CIELab MatrixXd Lab1(nHive, 3); //MatrixXd RGBTmpVec(nHive + 2, 3); //MatrixXd VolumeHive(nHive + 2, m_nVolumes); @@ -139,7 +139,7 @@ void Tango::ColorLib::ColorConverter::ProcessHiveNeighbors(VectorXd Lab, VectorX VectorXd xyz(3); VectorXd JabTmp(3); C_RGB_XYZ_Lab xyzVal, LabVal; - double *tmpRGB; + double *tmpRGB; double *InkOut = new double[m_nInks]; //int *GamutRegion = new int[nHive + 2]; int *GamutRegion = new int[nHive + 1]; @@ -165,11 +165,11 @@ void Tango::ColorLib::ColorConverter::ProcessHiveNeighbors(VectorXd Lab, VectorX //Check if whitepoints match //LabOut is under D65 illumination double * LabInFinal = Lab1P; - //Convert to CT WP - LabInFinal = m_Conv02->ChangeWP(LabInFinal, m_whitepointXYZ_CT, m_WP); //dest, source + //Convert to CT WP + LabInFinal = m_Conv02->ChangeWP(LabInFinal, m_whitepointXYZ_CT, m_WP); //dest, source if (m_AdaptWP) { - //Convert to Strip whitepoint + //Convert to Strip whitepoint LabInFinal = m_Conv02->ChangeWP(LabInFinal, m_whitepointXYZ_Strip, m_whitepointXYZ_CT); } m_Conv02->SetReferenceWhite(D65); @@ -177,7 +177,7 @@ void Tango::ColorLib::ColorConverter::ProcessHiveNeighbors(VectorXd Lab, VectorX tmpRGB = m_Conv02->LabtoRGB(LabInFinal); for (int j = 0; j < 3; ++j) RGBTmpVec(i, j) = std::min(std::max(tmpRGB[j], 0.0), 255.0); - + VectorXd InkOutV = DoubleToVector(InkOut, m_nInks); ConvertToNLInks(InkOutV, InkOutV); NLInkPToVolume(InkOutV, Vol); @@ -185,8 +185,8 @@ void Tango::ColorLib::ColorConverter::ProcessHiveNeighbors(VectorXd Lab, VectorX VolumeHive(i, j) = Vol(j); } //for (int i = 0; i < 2; ++i) - for (int i = 0; i < 1; ++i) - { + for (int i = 0; i < 1; ++i) + { for (j = 0; j < 3; ++j) { VolumeHive(nHive + i, j) = Volume(j); @@ -201,7 +201,7 @@ void Tango::ColorLib::ColorConverter::ProcessHiveNeighbors(VectorXd Lab, VectorX //Some of the matrix elements are empty ArrangeHiveData(RGBTmpVec, VolumeHive, GamutRegion, nHive, ORGBHive, OVolumeHive, OGamutRegion); FindTriplet(Lab, Lab1, nHive, indDataMax); - + if (InkOut != NULL) { delete[]InkOut; @@ -248,7 +248,7 @@ void Tango::ColorLib::ColorConverter::FindTriplet(VectorXd Lab, MatrixXd Lab1, int maxInd = 0; for (int i = 1; i < vecSize; ++i) { - if ((maxdE < dECMC[i]) && (dECMC[i]<5)) + if ((maxdE < dECMC[i]) && (dECMC[i] < 5)) { maxdE = dECMC[i]; maxInd = i; @@ -348,7 +348,7 @@ void Tango::ColorLib::ColorConverter::readColorTransformations(ConversionInput* ColorConvert CConvert(D65, D65); C_RGB_XYZ_Lab tmpW; tmpW = CConvert.LabToXYZ(m_whitepointLab); - m_whitepointXYZ_Strip.Set(tmpW.Get_x(), tmpW.Get_y(), tmpW.Get_z()); + m_whitepointXYZ_Strip.Set(tmpW.Get_x(), tmpW.Get_y(), tmpW.Get_z()); } else { @@ -374,13 +374,13 @@ void Tango::ColorLib::ColorConverter::readColorTransformations(ConversionInput* char *tmpC; int n = 0; int i, j; - for ( i = 0; i < tag_count; ++i) + for (i = 0; i < tag_count; ++i) { TagSize[i] = new int[3]; - tmp =conv.ByteToInt(buff, bytesread); + tmp = conv.ByteToInt(buff, bytesread); tmpC = conv.getchar(tmp, n); TagNames[i] = new char[n]; - for (j = 0; j<n; ++j) + for (j = 0; j < n; ++j) TagNames[i][j] = tmpC[j]; bytesread += 4; TagSize[i][0] = conv.ByteToInt(buff, bytesread); @@ -391,17 +391,17 @@ void Tango::ColorLib::ColorConverter::readColorTransformations(ConversionInput* int *TList = new int[tag_count]; for (int k = 0; k < tag_count; ++k) { - if (strncmp(TagNames[k], "A2B ",4) ==0) + if (strncmp(TagNames[k], "A2B ", 4) == 0) TList[k] = A2B; - else if (strncmp(TagNames[k], "B2A ",4)==0) + else if (strncmp(TagNames[k], "B2A ", 4) == 0) TList[k] = B2A; - else if (strncmp(TagNames[k], "wtpt",4)==0) + else if (strncmp(TagNames[k], "wtpt", 4) == 0) TList[k] = wtpt; - else if (strncmp(TagNames[k], "desc",4)==0) + else if (strncmp(TagNames[k], "desc", 4) == 0) TList[k] = desc; - else if (strncmp(TagNames[k], "gbd ",4)==0) + else if (strncmp(TagNames[k], "gbd ", 4) == 0) TList[k] = gbd; - else if (strncmp(TagNames[k], "cprt",2)==0) + else if (strncmp(TagNames[k], "cprt", 2) == 0) TList[k] = cprt; else throw std::exception("Unknown Tag in Color Tables"); @@ -459,7 +459,7 @@ void Tango::ColorLib::ColorConverter::readColorTransformations(ConversionInput* } } - } + } for (int i = 0; i < tag_count; ++i) { delete[] TagNames[i]; @@ -487,7 +487,7 @@ void Tango::ColorLib::ColorConverter::readColorTransformations(ConversionInput* throw std::exception("Missing Gamut Boundary Descriptor in Color Tables"); return; } - if ((m_whitepointXYZ_CT.Get_x() ==-1) && (m_whitepointXYZ_CT.Get_y() == -1) && (m_whitepointXYZ_CT.Get_z() == -1)) + if ((m_whitepointXYZ_CT.Get_x() == -1) && (m_whitepointXYZ_CT.Get_y() == -1) && (m_whitepointXYZ_CT.Get_z() == -1)) { throw std::exception("Missing Whitepoint in Color Tables"); return; @@ -495,40 +495,40 @@ void Tango::ColorLib::ColorConverter::readColorTransformations(ConversionInput* return; // OK } - void Tango::ColorLib::ColorConverter::readCalibrationTables(ConversionInput* conversionInput) +void Tango::ColorLib::ColorConverter::readCalibrationTables(ConversionInput* conversionInput) +{ + SetNumberofInks((int)(conversionInput->inputcoordinates->n_inputliquids)); + CalibData *CalibCurves = new CalibData[m_nInks]; + m_CalibCurves = new CalibData[m_nInks]; + for (int i = 0; i < m_nInks; ++i) { - SetNumberofInks((int)(conversionInput->inputcoordinates->n_inputliquids)); - CalibData *CalibCurves = new CalibData[m_nInks]; - m_CalibCurves = new CalibData[m_nInks]; - for (int i = 0; i < m_nInks; ++i) + InputLiquid* InkType = conversionInput->inputcoordinates->inputliquids[i]; + //CalibCurves[i].SetCalibName((int)(InkType->calibrationdata->liquidtype)); + m_CalibCurves[i].SetCalibName((int)(InkType->calibrationdata->liquidtype)); + //CalibCurves[i].SetMaxNlPerCM(conversionInput->inputcoordinates->inputliquids[i]->maxnanoliterpercentimeter); + m_CalibCurves[i].SetMaxNlPerCM(conversionInput->inputcoordinates->inputliquids[i]->maxnanoliterpercentimeter); + switch (InkType->calibrationdata->liquidtype) { - InputLiquid* InkType = conversionInput->inputcoordinates->inputliquids[i]; - //CalibCurves[i].SetCalibName((int)(InkType->calibrationdata->liquidtype)); - m_CalibCurves[i].SetCalibName((int)(InkType->calibrationdata->liquidtype)); - //CalibCurves[i].SetMaxNlPerCM(conversionInput->inputcoordinates->inputliquids[i]->maxnanoliterpercentimeter); - m_CalibCurves[i].SetMaxNlPerCM(conversionInput->inputcoordinates->inputliquids[i]->maxnanoliterpercentimeter); - switch (InkType->calibrationdata->liquidtype) - { - case LIQUID_TYPE__Cyan: - case LIQUID_TYPE__Magenta: - case LIQUID_TYPE__Yellow: - case LIQUID_TYPE__Black: - { - // calibration data. - CalibrationData* calibrationData = InkType->calibrationdata; - SetCalibData(calibrationData, i, &m_CalibCurves[i]); - break; - } - default: - { - throw std::exception("could not fill all calibration tables"); - return; - } - } + case LIQUID_TYPE__Cyan: + case LIQUID_TYPE__Magenta: + case LIQUID_TYPE__Yellow: + case LIQUID_TYPE__Black: + { + // calibration data. + CalibrationData* calibrationData = InkType->calibrationdata; + SetCalibData(calibrationData, i, &m_CalibCurves[i]); + break; + } + default: + { + throw std::exception("could not fill all calibration tables"); + return; + } } - // m_CalibCurves=CalibCurves; - return; } + // m_CalibCurves=CalibCurves; + return; +} void Tango::ColorLib::ColorConverter::SetCalibData(CalibrationData *calibrationData, int i, CalibData *tmpCurve) @@ -536,9 +536,9 @@ void Tango::ColorLib::ColorConverter::SetCalibData(CalibrationData *calibrationD if (calibrationData->calibrationpoints <= 0) { char msg[100]; - int n = - strcpy_s (msg, 100, "No Calibration points in table "); - + int n = + strcpy_s(msg, 100, "No Calibration points in table "); + throw std::exception(msg); return; } @@ -569,7 +569,7 @@ void Tango::ColorLib::ColorConverter::SetCalibData(CalibrationData *calibrationD return; } -void Tango::ColorLib::ColorConverter::ConvertColorToLinearInks(ConversionInput* conversionInput, VectorXd &InkOut, VectorXd &RGBOut, +void Tango::ColorLib::ColorConverter::ConvertColorToLinearInks(ConversionInput* conversionInput, VectorXd &InkOut, VectorXd &RGBOut, VectorXd &LabOut, int &GamutRegion, bool &InGamut) { size_t nInks = 0; @@ -589,7 +589,7 @@ void Tango::ColorLib::ColorConverter::ConvertColorToLinearInks(ConversionInput* //3. Convert Inks to Lab (A2B tables) to get the in/on Gamut Lab //4. Convert Lab to Absolute colorimetric taking into account the Strip and CT whitepoints //5. Use the above Lab to obtain RGB - + RGBOut(0) = conversionInput->inputcoordinates->red; RGBOut(1) = conversionInput->inputcoordinates->green; RGBOut(2) = conversionInput->inputcoordinates->blue; @@ -599,7 +599,7 @@ void Tango::ColorLib::ColorConverter::ConvertColorToLinearInks(ConversionInput* double *RGBOutP = VectorToDouble(RGBOut); //RGB to Lab LabIn = CConvertD65.RGBtoLab(RGBOutP); //Values are in Relative Colorimetric, D65 - + double *LabInFinal = LabIn; //Is In Gamut? InGamut = IsInGamut(LabIn, sur); @@ -609,19 +609,19 @@ void Tango::ColorLib::ColorConverter::ConvertColorToLinearInks(ConversionInput* //LabInFinal is in Relative Colorimetric, just like the Color Tables m_B2ATransform->evalLab2InkP(LabInFinal, InkOutP, GamutRegion); //InkOut is in units of 16 bits InkOut = DoubleToVector(InkOutP, m_nInks); - //Convert to Lab to get the actual in Gamut Lab + //Convert to Lab to get the actual in Gamut Lab double *LabInP = new double[3]; m_A2BTransform->evalInkP2Lab(InkOutP, LabInP, GamutRegion); //Lab is in Relative Colorimetric LabOut = DoubleToVector(LabInP, 3); - //Convert to CT thread, LabIn is in Relative Colorimetric Space + //Convert to CT thread, LabIn is in Relative Colorimetric Space LabInFinal = CConvertD65.ChangeWP(LabInP, m_whitepointXYZ_CT, m_WP); - //check if the thread to be used is the same as the one in the color tables + //check if the thread to be used is the same as the one in the color tables if (m_AdaptWP) { //Convert to Strip White Point LabInFinal = CConvertD65.ChangeWP(LabInFinal, m_whitepointXYZ_Strip, m_whitepointXYZ_CT); } - + CConvertD65.SetReferenceWhite(D65); //Get the Gamut Mapped RGB Based on Absolute Colorimetric Data RGBOutP = CConvertD65.LabtoRGB(LabInFinal); @@ -686,7 +686,7 @@ void Tango::ColorLib::ColorConverter::ConvertColorToLinearInks(ConversionInput* LabOutFinal = CConvertD65.ChangeWP(LabOutFinal, m_whitepointXYZ_CT, m_WP); if (m_AdaptWP) { - LabOutFinal = CConvertD65.ChangeWP(LabOutFinal, m_whitepointXYZ_Strip, m_whitepointXYZ_CT ); + LabOutFinal = CConvertD65.ChangeWP(LabOutFinal, m_whitepointXYZ_Strip, m_whitepointXYZ_CT); } CConvertD65.SetReferenceWhite(D65); //Convert to RGB @@ -743,7 +743,7 @@ void Tango::ColorLib::ColorConverter::ConvertColorToLinearInks(ConversionInput* LabOutFinal = CConvertD65.ChangeWP(LabOutFinal, m_whitepointXYZ_CT, m_WP); if (m_AdaptWP) {//check if this is needed - LabOutFinal = CConvertD65.ChangeWP(LabOutFinal, m_whitepointXYZ_Strip, m_whitepointXYZ_CT); + LabOutFinal = CConvertD65.ChangeWP(LabOutFinal, m_whitepointXYZ_Strip, m_whitepointXYZ_CT); } LabOut = DoubleToVector(LabOutFinal, 3); CConvertD65.SetReferenceWhite(D65); @@ -811,7 +811,7 @@ void Tango::ColorLib::ColorConverter::ConvertToNLInks(VectorXd InkIn, VectorXd LinInterp.Init(xValues, yValues, m_CalibCurves[i].getSize()); LinInterp.Eval(InkIn(i), InkOut(i)); } - + return; } @@ -828,7 +828,7 @@ void Tango::ColorLib::ColorConverter::ConvertToLinearInks(VectorXd InkIn, Vecto LinInterp.Init(xValues, yValues, m_CalibCurves[i].getSize()); LinInterp.Eval(InkIn(i), InkOut(i)); } - + return; } @@ -960,7 +960,7 @@ void Tango::ColorLib::ColorConverter::ConvertVolumeToRGBDisplay(ConversionInput* VolumeToNLInkP(Volume, NLInkP); //Convert to Linear Inks - ConvertToLinearInks(NLInkP, InkOut); + ConvertToLinearInks(NLInkP, InkOut); //Convert to RGB GamutRegion = 0; @@ -969,7 +969,7 @@ void Tango::ColorLib::ColorConverter::ConvertVolumeToRGBDisplay(ConversionInput* double *LabOutP = new double[m_nA2BnSepOut]; for (int i = 0; i < m_nA2BnSepIn; ++i) InkOutP[i] = InkOut(i); - m_A2BTransform->evalInkP2Lab(InkOutP, LabOutP, GamutRegion); + m_A2BTransform->evalInkP2Lab(InkOutP, LabOutP, GamutRegion); //LabOut is in Relative Colorimetric ColorConvert CConvertD65(D65, D65); @@ -1027,12 +1027,43 @@ VectorXd Tango::ColorLib::ColorConverter::DoubleToVector(double *doub, int nSize size_t Tango::ColorLib::ColorConverter::Convert(uint8_t * input_buffer, size_t input_buffer_size, uint8_t *& output_buffer) { - + //Get Input ConversionInput* conversionInput = (ConversionInput*)malloc(sizeof(ConversionInput)); conversionInput = conversion_input__unpack(NULL, input_buffer_size, input_buffer); + + + //Filter and arrange colors (Should change from 3 to 4 if black ink is included) + int expected_liquids = 3; + + InputLiquid** filteredInputLiquids = (InputLiquid**)malloc(sizeof(InputLiquid*) * expected_liquids); + + for (size_t i = 0; i < conversionInput->inputcoordinates->n_inputliquids; i++) + { + InputLiquid* liquid = conversionInput->inputcoordinates->inputliquids[i]; + + switch (liquid->liquidtype) + { + case LIQUID_TYPE__Cyan: + filteredInputLiquids[0] = liquid; + break; + case LIQUID_TYPE__Magenta: + filteredInputLiquids[1] = liquid; + break; + case LIQUID_TYPE__Yellow: + filteredInputLiquids[2] = liquid; + break; + } + } + + conversionInput->inputcoordinates->inputliquids = filteredInputLiquids; + conversionInput->inputcoordinates->n_inputliquids = expected_liquids; + //Filter and arrange colors + + + //Initialize Output... ConversionOutput *conversionOutput = (ConversionOutput*)malloc(sizeof(ConversionOutput)); conversion_output__init(conversionOutput); @@ -1059,7 +1090,7 @@ size_t Tango::ColorLib::ColorConverter::Convert(uint8_t * input_buffer, size_t i CompareWhitePoints(); readCalibrationTables(conversionInput); - if(numofInks != m_nB2AnSepOut) + if (numofInks != m_nB2AnSepOut) throw std::exception("Number of available inks does not match ink tables"); VectorXd InkOut(m_nB2AnSepOut); @@ -1078,12 +1109,12 @@ size_t Tango::ColorLib::ColorConverter::Convert(uint8_t * input_buffer, size_t i //Convert input data to linear inks if (conversionInput->colorspace == COLOR_SPACE__Volume) { - ConvertVolumeToRGBDisplay(conversionInput, Volume, RGBOut, LabOut, GamutRegion); + ConvertVolumeToRGBDisplay(conversionInput, Volume, RGBOut, LabOut, GamutRegion); InGamut = true; } else { - ConvertColorToLinearInks(conversionInput, InkOut, RGBOut, LabOut, GamutRegion, InGamut); + ConvertColorToLinearInks(conversionInput, InkOut, RGBOut, LabOut, GamutRegion, InGamut); //Convert to Nonlinear Inks ConvertToNLInks(InkOut, NLInkOut); //Convert to [nl/cm] @@ -1169,15 +1200,15 @@ size_t Tango::ColorLib::ColorConverter::Convert(uint8_t * input_buffer, size_t i conversionOutput->triplecoordinates[i] = TripletData[i]; } -/* //Clean up - if (GamutRegionV != NULL) - { - delete GamutRegionV; - GamutRegionV = NULL; - } */ - + /* //Clean up + if (GamutRegionV != NULL) + { + delete GamutRegionV; + GamutRegionV = NULL; + } */ - //Pack output... + + //Pack output... output_buffer = (uint8_t*)malloc(conversion_output__get_packed_size(conversionOutput)); int size = conversion_output__pack(conversionOutput, output_buffer); @@ -1214,7 +1245,7 @@ bool Tango::ColorLib::ColorConverter::IsInGamut(double *InLab, SURROUND sur) ctr[1] = -JLab(1) + center.Get_y(); ctr[2] = -JLab(2) + center.Get_z(); double *dJLab; - dJLab=VectorToDouble(JLab); + dJLab = VectorToDouble(JLab); bool intersect = false; m_GBD->TriangleRayIntersection(dJLab, ctr, intersect, xCoord); if (intersect) @@ -1234,7 +1265,7 @@ bool Tango::ColorLib::ColorConverter::IsInGamut(double *InLab, SURROUND sur) InGamut = true; if (xCoord != NULL) { - delete [] xCoord; + delete[] xCoord; xCoord = NULL; } return(InGamut); @@ -1244,15 +1275,15 @@ bool Tango::ColorLib::ColorConverter::IsInGamut(double *InLab, SURROUND sur) Tango::CT_Header Tango::ColorLib::ColorConverter::read_header(ConversionInput* conversionInput, int &bytesread) { CT_Header *Header = new CT_Header; -// unsigned int tmp = (buffer[2 * i + 1] << 8) | buffer[2 * i]; + // unsigned int tmp = (buffer[2 * i + 1] << 8) | buffer[2 * i]; uint8_t *ColorTable = conversionInput->forwarddata.data; //File Size NumConversions Conv; - Header->TblSIze = Conv.ByteToInt(ColorTable, bytesread) ; + Header->TblSIze = Conv.ByteToInt(ColorTable, bytesread); bytesread = 4; uint8_t versionBCT[2]; versionBCT[0] = (unsigned int)ColorTable[bytesread]; - bytesread +=1; + bytesread += 1; versionBCT[1] = (unsigned int)ColorTable[bytesread]; Header->Version[0] = versionBCT[0]; Header->Version[1] = versionBCT[1] << 4; @@ -1260,12 +1291,12 @@ Tango::CT_Header Tango::ColorLib::ColorConverter::read_header(ConversionInput* c bytesread += 1; uint32_t tmp = Conv.ByteToInt(ColorTable, bytesread); int n = 0; - char *tmpC ; + char *tmpC; tmpC = Conv.getchar(tmp, n); Header->ColorSpace = new char[n]; - Header->ColorSpace= tmpC; + Header->ColorSpace = tmpC; bytesread += 4; - tmp = Conv.ByteToInt(ColorTable, bytesread); + tmp = Conv.ByteToInt(ColorTable, bytesread); tmpC = Conv.getchar(tmp, n); Header->ConnectionSpace = tmpC; bytesread += 4; @@ -1287,10 +1318,10 @@ Tango::CT_Header Tango::ColorLib::ColorConverter::read_header(ConversionInput* c if (bytesread < 128) { bytesread = 128; - return(*Header); + return(*Header); } else - { + { throw std::exception("could not read Color table Header"); } } @@ -1323,48 +1354,48 @@ void Tango::ColorLib::ColorConverter::read_lut_type(int offset, int data_size, C void Tango::ColorLib::ColorConverter::read_xyz_type(int offset, int data_size, C_RGB_XYZ_Lab *XYZ, ConversionInput* conversionInput) { -// 0 - 3 'XYZ ' -//4 - 7 reserved, must be 0 -// 8 - n array of XYZ numbers + // 0 - 3 'XYZ ' + //4 - 7 reserved, must be 0 + // 8 - n array of XYZ numbers -if (data_size < 8) -{ - throw std::exception("not enough data to read xyz"); -} -uint8_t *buff = &(conversionInput->forwarddata.data[offset]); -NumConversions Conv; -int bytesread = 0; -int tmpxyz = Conv.ByteToInt(buff, bytesread); -char* tmpC; -int n = 0; -tmpC = Conv.getchar(tmpxyz, n); + if (data_size < 8) + { + throw std::exception("not enough data to read xyz"); + } + uint8_t *buff = &(conversionInput->forwarddata.data[offset]); + NumConversions Conv; + int bytesread = 0; + int tmpxyz = Conv.ByteToInt(buff, bytesread); + char* tmpC; + int n = 0; + tmpC = Conv.getchar(tmpxyz, n); -char *xyztype = new char[n+1]; -strncpy_s(xyztype, n+1,tmpC, n); -if (strncmp(xyztype, "XYZ ",n) !=0) -{ - throw std::exception("Wrong Tag Type"); - return; -} -delete[] xyztype; -bytesread = 8; -int num_values = (data_size - 8) / 4; -if (floor((double)(num_values) / 3) * 3 != num_values) -{ - throw std::exception("not enough Data to read xyz"); + char *xyztype = new char[n + 1]; + strncpy_s(xyztype, n + 1, tmpC, n); + if (strncmp(xyztype, "XYZ ", n) != 0) + { + throw std::exception("Wrong Tag Type"); + return; + } + delete[] xyztype; + bytesread = 8; + int num_values = (data_size - 8) / 4; + if (floor((double)(num_values) / 3) * 3 != num_values) + { + throw std::exception("not enough Data to read xyz"); + return; + } + double xyz[3]; + int tmp; + for (int j = 0; j < 3; ++j) + { + tmp = Conv.ByteToInt(buff, bytesread); + xyz[j] = (double)(tmp) / 65536; + bytesread += 4; + } + XYZ->Set(xyz[0], xyz[1], xyz[2]); return; } -double xyz[3]; -int tmp; -for (int j = 0; j < 3; ++j) -{ - tmp = Conv.ByteToInt(buff, bytesread); - xyz[j] = (double)(tmp) / 65536; - bytesread += 4; -} -XYZ->Set(xyz[0], xyz[1], xyz[2]); -return; -} void Tango::ColorLib::ColorConverter::read_text_type(int offset, int data_size, std::string *textstr, ConversionInput* conversionInput) @@ -1389,9 +1420,9 @@ void Tango::ColorLib::ColorConverter::read_text_type(int offset, int data_size, int n = 0; char *tmpC; tmpC = Conv.getchar(tmp, n); - char *tagtype = new char[n+1]; - strncpy_s(tagtype,n+1, tmpC, n); - if (strcmp(tagtype, "text") !=0) + char *tagtype = new char[n + 1]; + strncpy_s(tagtype, n + 1, tmpC, n); + if (strcmp(tagtype, "text") != 0) { throw std::exception("invalid Tag Name"); strstr << ""; @@ -1404,7 +1435,7 @@ void Tango::ColorLib::ColorConverter::read_text_type(int offset, int data_size, for (int i = bytesread; i < data_size; ++i) { tmp1 = buff[i]; - strstr.put( tmp1); + strstr.put(tmp1); } *textstr = strstr.str(); return; @@ -1426,10 +1457,10 @@ void Tango::ColorLib::ColorConverter::read_text_description_type(int offset, int int n = 0; char *tmpC; tmpC = Conv.getchar(tmp, n); - char *tagtype = new char[n+1]; - strncpy_s(tagtype, n+1, tmpC, n); + char *tagtype = new char[n + 1]; + strncpy_s(tagtype, n + 1, tmpC, n); std::stringstream strstr; - if (strcmp(tagtype, "desc") !=0) + if (strcmp(tagtype, "desc") != 0) { throw std::exception("invalid Tag Name"); strstr << ""; diff --git a/Software/Visual_Studio/Native/Tango.ColorLib/PMR/ColorLab/ColorSpace.pb-c.c b/Software/Visual_Studio/Native/Tango.ColorLib/PMR/ColorLab/ColorSpace.pb-c.c index 23f827f18..b67d99784 100644 --- a/Software/Visual_Studio/Native/Tango.ColorLib/PMR/ColorLab/ColorSpace.pb-c.c +++ b/Software/Visual_Studio/Native/Tango.ColorLib/PMR/ColorLab/ColorSpace.pb-c.c @@ -7,23 +7,25 @@ #endif #include "ColorSpace.pb-c.h" -static const ProtobufCEnumValue color_space__enum_values_by_number[5] = +static const ProtobufCEnumValue color_space__enum_values_by_number[6] = { { "Volume", "COLOR_SPACE__Volume", 0 }, { "RGB", "COLOR_SPACE__RGB", 1 }, { "CMYK", "COLOR_SPACE__CMYK", 2 }, { "LAB", "COLOR_SPACE__LAB", 3 }, { "PANTON", "COLOR_SPACE__PANTON", 4 }, + { "Twine", "COLOR_SPACE__Twine", 5 }, }; static const ProtobufCIntRange color_space__value_ranges[] = { -{0, 0},{0, 5} +{0, 0},{0, 6} }; -static const ProtobufCEnumValueIndex color_space__enum_values_by_name[5] = +static const ProtobufCEnumValueIndex color_space__enum_values_by_name[6] = { { "CMYK", 2 }, { "LAB", 3 }, { "PANTON", 4 }, { "RGB", 1 }, + { "Twine", 5 }, { "Volume", 0 }, }; const ProtobufCEnumDescriptor color_space__descriptor = @@ -33,9 +35,9 @@ const ProtobufCEnumDescriptor color_space__descriptor = "ColorSpace", "ColorSpace", "", - 5, + 6, color_space__enum_values_by_number, - 5, + 6, color_space__enum_values_by_name, 1, color_space__value_ranges, diff --git a/Software/Visual_Studio/Native/Tango.ColorLib/PMR/ColorLab/ColorSpace.pb-c.h b/Software/Visual_Studio/Native/Tango.ColorLib/PMR/ColorLab/ColorSpace.pb-c.h index 2f25ef087..07226817d 100644 --- a/Software/Visual_Studio/Native/Tango.ColorLib/PMR/ColorLab/ColorSpace.pb-c.h +++ b/Software/Visual_Studio/Native/Tango.ColorLib/PMR/ColorLab/ColorSpace.pb-c.h @@ -24,7 +24,8 @@ typedef enum _ColorSpace { COLOR_SPACE__RGB = 1, COLOR_SPACE__CMYK = 2, COLOR_SPACE__LAB = 3, - COLOR_SPACE__PANTON = 4 + COLOR_SPACE__PANTON = 4, + COLOR_SPACE__Twine = 5 PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(COLOR_SPACE) } ColorSpace; |
