Example #1
0
void TestFileGenerator::WriteSmallDatFileWithReservedStringParameters()
{
	int32_t rows = 4;
	int32_t cols = 5;
	int32_t pixelCount = rows*cols;
	DATData data("small_dat_file_with_reserved_string_parameters");
	data.SetPixelCount(pixelCount);
	data.SetStatsCount(1);
	data.SetArrayType(L"Hg_small");
	data.SetPixelSize(0.71f);
	data.SetScannerType(L"M10");
	data.SetScannerID(L"main");
	DateTime dt = DateTime::Parse(L"2005-12-25T11:12:13Z");
	data.SetScanDate(dt);
	data.SetRows(rows);
	data.SetCols(cols);
	std::string arrayId = "smellsliketeenspirit";
	data.SetArrayId(arrayId);
	
	ParameterNameValueType nvt;
	nvt.SetName(L"fixedlen");
	nvt.SetValueText(L"twenty-five", 25);
	data.GetFileHeader()->GetGenericDataHdr()->AddNameValParam(nvt);

	DATFileWriter writer(data);

	Uint16Vector pixels;
	pixels.reserve(pixelCount);

	u_int16_t inten = 10;
	for (int32_t i=0; i<pixelCount; ++i, ++inten)
	{
		if (inten > 46000)
		{
			inten = 0;
		}
		pixels.push_back(inten);
	}

	Uint16Vector stats;
	stats.push_back(pixels[0]);	// min
	stats.push_back(pixels[19]);	// max

	writer.WriteStats(stats);
	writer.WritePixels(pixels);
}
Example #2
0
void TestFileGenerator::WriteDatFile(const std::string& name, const std::wstring& type, int32_t rows, int32_t cols, bool showProgress)
{
	cout << "Started writing " << name.c_str() << endl;

	int32_t pixelCount = rows*cols;
	DATData data(name);
	data.SetPixelCount(pixelCount);
	data.SetStatsCount(1);
	data.SetArrayType(type);
	data.SetPixelSize(0.71f);
	data.SetScannerType(L"M10");
	data.SetScannerID(L"main");
	DateTime dt = DateTime::Parse(L"2005-12-25T11:12:13Z");
	data.SetScanDate(dt);
	data.SetRows(rows);
	data.SetCols(cols);
	DATFileWriter writer(data);

	Uint16Vector pixels;
	pixels.reserve(pixelCount);

	u_int16_t inten = 10;
	for (int32_t i=0; i<pixelCount; ++i, ++inten)
	{
		if (inten > 46000)
		{
			inten = 0;
			if (showProgress)
				cout << "Written " << i << " pixels so far..." << endl;
		}
		pixels.push_back(inten);
	}

	Uint16Vector stats;
	stats.push_back(pixels[0]);	// min
	stats.push_back(pixels[19]);	// max

	writer.WriteStats(stats);
	writer.WritePixels(pixels);

	cout << "Completed writing " << name.c_str() << endl;
}