67 #define BUFFER_SIZE 1024 76 int width=0, height=0, depth=0, bytealign=1;
82 if ( sscanf(line.c_str(),
"%s %s", buffer, filename) != 2 )
87 if ( sscanf(line.c_str(),
"%s %d %d %d", buffer, &width, &height, &depth) != 4 )
90 if ( sscanf(line.c_str(),
"%s %f %f %f", buffer, &a,&b,&c) != 4 )
93 if ( sscanf(line.c_str(),
"%s %s", buffer, typ) != 2 )
98 if ( sscanf(line.c_str(),
"%s %s", buffer, fmt) != 2 )
105 int len = (int)strlen(filename);
108 if (filename[0] ==
'\'' || filename[0] ==
'"')
109 memmove(filename, filename + 1, len);
110 len = (int)strlen(filename);
111 if (filename[len-1] ==
'\'' || filename[len-1] ==
'"')
118 if (
String(typ) ==
"UCHAR")
121 if (
String(typ) ==
"USHORT")
125 Log::error(
Say(
"loadDAT('%s'): type '%s' not supported.\n") << file->
path() << typ );
129 if (
String(fmt) ==
"LUMINANCE")
132 if (
String(fmt) ==
"LUMINANCE_ALPHA")
138 if (
String(fmt) ==
"RGBA")
142 Log::error(
Say(
"loadDAT('%s'): format '%s' not supported.\n") << file->
path() << fmt );
149 return loadRAW( rawf.
get(), -1, width, height, depth, bytealign, format, type );
153 Log::error(
Say(
"loadDAT('%s'): could not find RAW file '%s'.\n") << file->
path() << raw_file );
160 #define BUFFER_SIZE 1024 172 int width=0, height=0, depth=0;
178 if ( sscanf(line.c_str(),
"%s %s", buffer, filename) != 2 )
183 if ( sscanf(line.c_str(),
"%s %d %d %d", buffer, &width, &height, &depth) != 4 )
186 if ( sscanf(line.c_str(),
"%s %f %f %f", buffer, &a,&b,&c) != 4 )
189 if ( sscanf(line.c_str(),
"%s %s", buffer, typ) != 2 )
194 if ( sscanf(line.c_str(),
"%s %s", buffer, fmt) != 2 )
201 int len = (int)strlen(filename);
204 if (filename[0] ==
'\'' || filename[0] ==
'"')
205 memmove(filename,filename + 1, len);
206 len = (int)strlen(filename);
207 if (filename[len-1] ==
'\'' || filename[len-1] ==
'"')
215 if (
String(typ) !=
"UCHAR")
218 if (
String(fmt) !=
"LUMINANCE" &&
String(fmt) !=
"LUMINANCE_ALPHA" &&
String(fmt) !=
"RGB" &&
String(fmt) !=
"RGBA")
VLCORE_EXPORT FileSystem * defFileSystem()
Returns the default FileSystem used by VisualizationLibrary.
An abstract class representing a file.
bool readLine(std::string &utf8)
A simple String formatting class.
The String class implements an advanced UTF16 (Unicode BMP) string manipulation engine.
VLCORE_EXPORT ref< Image > loadRAW(VirtualFile *file, long long file_offset, int width, int height, int depth, int bytealign, EImageFormat format, EImageType type)
Loads a raw image file.
static void error(const String &message)
Use this function to provide information about run-time errors: file not found, out of memory...
String extractPath() const
If the String contains a file path the function returns the path with trailing slash, without the file name.
virtual ref< VirtualFile > locateFile(const String &full_path, const String &alternate_path=String()) const
Looks for a VirtualFile on the disk and in the currently active FileSystem.
VLCORE_EXPORT ref< Image > loadDAT(VirtualFile *file)
virtual void close()=0
Closes the file.
const String & path() const
Returns the path of the file.
Visualization Library main namespace.
The TextStream class can be used to conveniently read or parse utf8-encoded text files.
VLCORE_EXPORT bool isDAT(VirtualFile *file)
virtual bool open(EOpenMode mode)=0
Opens the file in the specified mode.
VLCORE_EXPORT ref< VirtualFile > locateFile(const String &path)
Utility function, equivalent to vl::defFileSystem()->locateFile(path)
The ref<> class is used to reference-count an Object.