// Загружает INI-структуру из файла. При возникновении ошибки возвращает false // file - файл для загрузки bool IniFile::Load(const String& file, int charset) { FileIn in; if (!in.Open(file)) return false; bool r = Load(in, charset); in.Close(); return r; }
void TestLeptonica::onPageLayout() { String fileName; FileSelector fs; Pix source; if(!PromptYesNo( "[= [* Page layout analysis demo]&&" "Please select a 1 bpp scanned image with mixed text and graphics&" "you can take one from TestLeptonica folder if you like&&" "[* CONTINUE ??]]" )) return; fs.ReadOnlyOption(); if(fs.ExecuteOpen("Please select image for page layout analysis:")) { FileIn s; if(!s.Open(~fs)) { PromptOK("Error opening image"); s.Close(); return; } // Loads pixraster from source raster CHECKR(source.Load(s), "Error loading image"); s.Close(); // apply line removal algothithm pixRaster.Clear(); PageLayout(source, pixRaster); // refresh the PixRasterCtrl control with the new image contents pixRasterCtrl.Reload(); pixRasterCtrl.SetPage(0); } }
void PosOverrunTest() { String tmpfile = GetTempFileName("pos"); FileOut fo; if(!fo.Open(tmpfile)) { Cout() << "PosOverrunTest: error creating file " << tmpfile << "\n"; return; } for(int i = 0; i < 0x10000; i++) fo.PutIW(i); int64 size = fo.GetSize(); fo.Close(); if(fo.IsError() || size != 0x20000) { Cout() << "PosOverrunTest generator error, file " << tmpfile << "\n"; return; } FileIn fi; fi.SetBufferSize(4096); if(!fi.Open(tmpfile)) { Cout() << "PosOverrunTest: error reopening temporary file " << tmpfile << "\n"; return; } for(int i = 0; i < 4096; i++) fi.Get(); char buffer[32]; fi.GetAll(buffer, 32); bool ok = true; for(int i = 0; i < 16; i++) { int strmval = PeekIW(buffer + 2 * i); int expect = 2048 + i; if(strmval != expect) { Cout() << "PosOverrunTest: " << FormatIntHex(expect, 4) << " expected, " << FormatIntHex(strmval, 4) << " found\n"; ok = false; } } if(ok) Cout() << "PosOverrunTest: finished without errors\n"; }