Example #1
0
void TScannerParameters::loadData(TIStream &is) {
  std::string tagName;
  while (is.matchTag(tagName)) {
    if (tagName == "dpi") {
      std::string s                  = is.getTagAttribute("value");
      if (isDouble(s)) m_dpi.m_value = std::stof(s);
    } else if (tagName == "brightness") {
      std::string s                         = is.getTagAttribute("value");
      if (isDouble(s)) m_brightness.m_value = std::stof(s);
    } else if (tagName == "threshold") {
      std::string s                        = is.getTagAttribute("value");
      if (isDouble(s)) m_threshold.m_value = std::stof(s);
    } else if (tagName == "contrast") {
      std::string s                       = is.getTagAttribute("value");
      if (isDouble(s)) m_contrast.m_value = std::stof(s);
    } else if (tagName == "autoFeeder") {
      m_paperFeeder.m_value = 1.0;
    } else if (tagName == "reverseOrder") {
      m_reverseOrder = true;
    } else if (tagName == "mode") {
      std::string scanTypeString = is.getTagAttribute("value");
      m_scanType                 = None;
      if (scanTypeString == BlackAndWhite)
        m_scanType = BW;
      else if (scanTypeString == Graytones)
        m_scanType = GR8;
      else if (scanTypeString == Rgbcolors)
        m_scanType = RGB24;
    } else if (tagName == "paper") {
      std::string paperFormat = is.getTagAttribute("fmt");
      if (paperFormat != "") setPaperFormat(paperFormat);
    }
  }
  m_validatedByCurrentScanner = false;
}
void CleanupParameters::loadData(TIStream &is, bool globalParams)
{
	if (globalParams) {
		CleanupParameters cp;
		assign(&cp);
	}

	std::string tagName;
	m_lineProcessingMode = lpNone;
	m_noAntialias = false;
	m_postAntialias = false;

	while (is.matchTag(tagName)) {
		if (tagName == "cleanupPalette") {
			m_cleanupPalette->loadData(is);
			m_cleanupPalette->setIsCleanupPalette(true);
			is.closeChild();
		} else if (tagName == "cleanupCamera") {
			m_camera.loadData(is);
			is.closeChild();
		} else if (tagName == "autoCenter") {
			m_autocenterType = AUTOCENTER_FDG;
			std::string s = is.getTagAttribute("type");
			if (s != "" && isInt(s))
				m_autocenterType = (AUTOCENTER_TYPE)toInt(s);
			s = is.getTagAttribute("pegHoles");
			if (s != "" && isInt(s))
				m_pegSide = (PEGS_SIDE)toInt(s);
		} else if (tagName == "transform") {
			std::string s = is.getTagAttribute("flip");
			m_flipx = (s.find("x") != std::string::npos);
			m_flipy = (s.find("y") != std::string::npos);
			s = is.getTagAttribute("rotate");
			if (s != "" && isInt(s))
				m_rotate = toInt(s);
			s = is.getTagAttribute("xoff");
			if (s != "" && isDouble(s))
				m_offx = toDouble(s);
			s = is.getTagAttribute("yoff");
			if (s != "" && isDouble(s))
				m_offy = toDouble(s);
		} else if (tagName == "lineProcessing") {
			m_lineProcessingMode = lpGrey;
			std::string s = is.getTagAttribute("sharpness");
			if (s != "" && isDouble(s))
				m_sharpness = toDouble(s);
			s = is.getTagAttribute("autoAdjust");
			if (s != "" && isDouble(s))
				m_autoAdjustMode = (CleanupTypes::AUTO_ADJ_MODE)toInt(s);
			s = is.getTagAttribute("mode");
			if (s != "" && s == "color")
				m_lineProcessingMode = lpColor;
		} else if (tagName == "despeckling") {
			std::string s = is.getTagAttribute("value");
			if (s != "" && isInt(s))
				m_despeckling = toInt(s);
		} else if (tagName == "aaValue") {
			std::string s = is.getTagAttribute("value");
			if (s != "" && isInt(s))
				m_aaValue = toInt(s);
		} else if (tagName == "noAntialias")
			m_noAntialias = true;
		else if (tagName == "MLAA")
			m_postAntialias = true;
		else if (tagName == "closestField") {
			std::string s = is.getTagAttribute("value");
			if (s != "" && isDouble(s))
				m_closestField = toDouble(s);
		} else if (tagName == "fdg") {
			std::string s = is.getTagAttribute("name");
			if (s != "")
				setFdgByName(s);
		} else if (tagName == "path") {
			is >> m_path;
			is.closeChild();
		} else