HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IMG_File.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: IMG_File.h ( IMG Library, C++)
7  *
8  * COMMENTS:
9  * Generic interface for loading and saving image files.
10  */
11 
12 #pragma once
13 
14 #ifndef __IMG_File__
15 #define __IMG_File__
16 
17 #include "IMG_API.h"
18 #include <iosfwd>
19 #include <SYS/SYS_Types.h>
20 #include <UT/UT_Array.h>
21 #include <UT/UT_ErrorManager.h>
22 #include <UT/UT_FilterType.h>
23 #include <UT/UT_Functor.h>
24 #include <UT/UT_Rect.h>
25 #include <UT/UT_ValArray.h>
26 #include <UT/UT_BitArray.h>
27 #include <UT/UT_WorkArgs.h>
28 #include <UT/UT_SharedPtr.h>
29 #include <UT/UT_StringArray.h>
30 #include <PXL/PXL_Forward.h>
31 #include "IMG_FileParms.h"
32 #include "IMG_Error.h"
33 #include "IMG_FileTypes.h"
34 #include "IMG_Stat.h"
35 
36 class IMG_Format;
37 class UT_Options;
38 class UT_String;
39 class UT_WorkBuffer;
40 class UT_FileLUT;
41 class UT_IStream;
42 class FS_Reader;
43 class FS_Writer;
44 class IMG_FileTagList;
45 class img_ScanProgress;
46 class PXL_Raster;
47 class PXL_DeepSampleList;
48 
50 
51 /// @brief Generic interface for reading and writing image files.
52 /// This class handles the reading and writing of all image formats that Houdini
53 /// supports. Use the static open() or create() methods to get an IMG_File
54 /// instance to read to or write from. Deleting this instance will close the
55 /// file.
57 {
58 public:
59  virtual ~IMG_File();
60 
61  virtual int64 getMemoryUsage(bool inclusive) const;
62 
63  // The following methods are a public interface which is not dependent on
64  // the format of the image. Users of the library should use these methods
65  // to do the loading and saving of the data.
66 
67  /// @brief Open an image file using a filename
68  /// Open an image file for reading by specifying the filename and path of
69  /// the file. An optional IMG_FileParms class may be passed to convert it
70  /// into a specific image type (8bit, specific resolution, etc). An optional
71  /// format may also be passed, which forces the library to assume the image
72  /// file is of that particular format.
73  /// This method returns a new IMG_File object which you read the image data
74  /// from, or NULL if an error occurred.
75  static IMG_File *open(const char *filename,
76  const IMG_FileParms *options = nullptr,
77  const IMG_Format *fmt = nullptr);
78 
79  /// @brief Open an image file using a filename
80  /// Open an image file for reading by specifying the filename and path of
81  /// the file. A list of formats is also given, allowing the caller
82  /// customization of the types and order of formats.
83  /// An optional IMG_FileParms class may be passed to convert it
84  /// into a specific image type (8bit, specific resolution, etc).
85  /// This method returns a new IMG_File object which you read the image data
86  /// from, or NULL if an error occurred.
87  static IMG_File *open(const char *filename,
88  const UT_Array<const IMG_Format*> &image_formats,
89  const IMG_FileParms *options = nullptr);
90 
91  /// @brief Open an image file from a stream
92  /// Open an image file for reading given a stream. This is useful for
93  /// embedded images in a file. An optional IMG_FileParms class may be
94  /// passed to convert it into a specific image type (8bit, specific
95  /// resolution, etc). An optional format may also be passed, which forces
96  /// the library to assume the image file is of that particular format.
97  /// If 'steal_stream' is true, the image library assumes ownership of the
98  /// stream and closes it when it's finished reading the file. If the stream
99  /// is not seekable (cannot jump around in the file, such as with a pipe),
100  /// set 'streamIsSeekable' to false.
101  /// This method returns a new IMG_File object which you read the image data
102  /// from, or NULL if an error occurred.
103  static IMG_File *open(UT_IStream &is,
104  const IMG_FileParms *options = nullptr,
105  const IMG_Format *fmt=nullptr,
106  int steal_stream = 0,
107  bool streamIsSeekable = true);
108 
109  /// @brief Create a new image file
110  /// Create a new image file with the pathname 'filename' according to the
111  /// parameters specified in 'stat'. You can supply an optional 'options'
112  /// class to translate the image before being written (scale, flip, etc).
113  /// You can also specify an optional 'format' parameter to force the file
114  /// to be written as a specific image format (regardless of the extension
115  /// found in 'filename').
116  /// NULL may be returned if the file could not be created for any reason.
117  static IMG_File *create(const char *filename,
118  const IMG_Stat &stat,
119  const IMG_FileParms *options = nullptr,
120  const IMG_Format *fmt = nullptr);
121 
122 
123  /// @brief Write an image file to an existing stream
124  /// Writes a new image file to the stream 'os' according to the
125  /// parameters specified in 'stat'. You can supply an optional 'options'
126  /// class to translate the image before being written (scale, flip, etc).
127  /// You can also specify an optional 'format' parameter to force the file
128  /// to be written as a specific image format (regardless of the extension
129  /// found in 'filename').
130  /// If 'steal_stream' is true, the image library assumes ownership of the
131  /// stream and closes it when it's finished writing the file. If the stream
132  /// is not seekable (cannot jump around in the file, such as with a pipe),
133  /// set 'streamIsSeekable' to false.
134  /// NULL may be returned if the file could not be created in the stream.
135  static IMG_File *create(std::ostream &os,
136  const IMG_Stat &stat,
137  const IMG_FileParms *options = nullptr,
138  const IMG_Format *fmt = nullptr,
139  int steal_stream = 0,
140  bool streamIsSeekable = true);
141 
142  /// @{
143  /// @brief Writes a PXL_Raster to an image file.
144  /// Convenience method to write an image stored in a PXL_Raster to a disk
145  /// file.
146  static bool saveRasterAsFile(const char *filename,
147  const PXL_Raster *raster,
148  const IMG_SaveRastersToFilesParms &parms);
149  static bool saveRasterAsFile(const char *filename,
150  const PXL_Raster *raster,
151  const IMG_FileParms *fparms = nullptr,
152  const IMG_Format *format = nullptr);
153  /// @}
154 
155  /// @brief Writes PXL_Raster's to image files.
156  /// Convenience method to write images stored in PXL_Raster's to disk
157  /// files. The @c linear_planes parameter specifies a pattern of planes
158  /// which should be written to in linear space.
159  static bool saveRastersAsFiles(const char *filename,
160  const IMG_SaveRastersToFilesParms &parms);
161 
162  /// @brief Copies an existing image file to another image file.
163  /// Convenience method to copy an image file from one file to another.
164  /// The image date may be altered if the formats of the two files are
165  /// not the same (based on filename extension), or if an optional 'options'
166  /// class is passed.
167  static bool copyToFile(const char *sourcename,
168  const char *destname,
169  const IMG_FileParms *options = nullptr);
170 
171  static bool copyToFileFormat(const char *sourcename,
172  const char *formatname,
173  UT_String *destname = nullptr,
174  const IMG_FileParms *options = nullptr);
175 
176  /// @brief Copies an existing image file to a stream
177  /// Convenience method to copy an image file to a stream. The image data
178  /// may be altered if an optional 'options' class is passed, or if the
179  /// optional image 'format' parameter does not match the format of the
180  /// source image file.
181  static bool copyToStream(const char *sourcename,
182  std::ostream &deststream,
183  const IMG_FileParms *options = nullptr,
184  const IMG_Format *format = nullptr);
185 
186  virtual const char *className() const { return "IMG_File"; }
187 
188  /// Closes the file. Called by the destructor if needed , so 'delete file'
189  /// will often take the place of this call. However, you won't receive any
190  /// error information in that case, so you can call it directly.
191  int close();
192 
193  /// Returns 1 if we are reading, 0 if writing.
194  int getReadMode() const;
195 
196  /// @{
197  /// Returns the image type of the format we just opened.
198  IMG_ImageType getImageType() const;
199  /// @}
200 
201  /// @{
202  /// Retrieve the file format description of the file. The format contains
203  /// all information that is general to all files of this format type.
204  const IMG_Format *getFormat() const { return myFormat; }
205  void setFormat(const IMG_Format *f) { myFormat = f; }
206  /// @}
207 
208  /// Get the image description of the current image file (resolution, data
209  /// format, etc). The returned class can be queried for all of the current
210  /// image file's statistics.
211  /// @{
212  const IMG_Stat &getStat() const;
213  IMG_Stat &getStat();
214  /// @}
215 
216  /// Get additional image information about the file that is specific
217  /// to a particular format. Some formats do not have additional information.
218  /// The information returned is human-readable in 'text'.
219  virtual void getAdditionalInfo(UT_String &text);
220 
221  /// returns the value of an image option passed in through IMG_FileParms.
222  /// Image options are specific to formats. Returns NULL if the option
223  /// does not exist on the format.
224  const char *getOption(const char *name) const;
225 
226  /// Access to the list of file options this file was saved with.
227  /// @{
228  int getNumOptions() const;
229  const char *getOptionName(int i) const;
230  const char *getOptionValue(int i) const;
231  /// @}
232 
233  /// @brief read a single scanline.
234  /// read() returns a pointer to the scanline data
235  /// in an internal buffer. Do not delete it.
236  const void *read(int scan, const IMG_Plane *from_plane = nullptr);
237 
238  /// @brief Reads the scanline into a buffer that you supply.
239  /// The buffer passed must be big enough to fit the plane passed.
240  /// getStat().bytesPerPlaneScan() will return the proper size.
241  /// Returns 0 on failure.
242  bool readIntoBuffer(int scan, void *buffer,
243  const IMG_Plane *from_plane = nullptr);
244 
245  /// @brief Write a scanline to the file.
246  /// You don't need to write scanlines in order, nor do you need to write
247  /// planes in order; the data may be cached however. Returns 0 if
248  /// there was an error during the write. You should immediately stop
249  /// writing if a failure occurred (many formats will behave unpredictably
250  /// otherwise).
251  bool write(int scan, const void *data,
252  const IMG_Plane *to_plane = nullptr);
253 
254  /// allocates a buffer large enough to hold the biggest plane's scanline
255  /// in the file. Free this buffer with free(). (This will not hold all
256  /// the planes' scanlines, only one at a time!)
257  void * allocScanlineBuffer() const;
258 
259  /// @deprecated
260  /// The following methods read/write a whole raster. Unless the scanline
261  /// increment is passed in, the stat structure will be used to determine the
262  /// scanline size. Beware if you're using translators...
263  /// Use readImages() and writeImages() instead.
264  ///@{
265  bool readImage(void *data, int flip=0, int scaninc=0);
266  /// @deprecated
267  bool writeImage(void *data, int flip=0, int scaninc=0);
268  ///@}
269 
270  /// @brief Reads all the image data into a list of PXL_Rasters.
271  /// reads the image data into a a series of rasters. The array should be
272  /// empty, as this method creates and fills the rasters for you.
273  ///
274  /// Note: You must delete the rasters returned by this method.
275  bool readImages(UT_Array<PXL_Raster *> &images,
276  const char *scope = nullptr);
277 
278  /// @{
279  /// @brief Writes all PXL_Rasters to the image format.
280  /// This method takes a raster per IMG_Plane in the stat. The
281  /// data format, color model and res of the raster must match the
282  /// corresponding IMG_Plane. If the format is not a deep raster format,
283  /// not all images may be written.
284  /// if 'freerasters' is true, it will free the rasters for you.
285  bool writeImages(const UT_Array<const PXL_Raster *> &imgs);
286  bool writeImages(UT_Array<PXL_Raster *> &images,
287  bool freerasters = false);
288  /// @}
289 
290  /// @deprecated
291  /// For image files that contain more than one image, such as a
292  /// movie file, jump to a particular frame in the movie and reset
293  /// for reading the scanlines of the new frame
294  virtual bool jumpToFrame(int frame);
295 
296  /// When writing an image, call if interrupted or you encounter an
297  /// non-image-file error and cannot complete the file write.
298  virtual void abortWrite();
299 
300  ///@{
301  /// orientation of the current file or format. Some formats support multiple
302  /// orientations specified in the image files themselves, others simply
303  /// have a fixed orientation. Call these methods rather than querying the
304  /// orientation from the format, in case the format supports multiple
305  /// orientations.
306  virtual int isTopFirst() const;
307  /// If 0, scanlines are right-to-left. Default is 1 (left-to-right).
308  virtual int isLeftFirst() const;
309  ///@}
310 
311  /// call this if you won't be reading the scanlines in order, or if
312  /// you'll be reading all the scanlines for a single plane first.
313  virtual void randomReadAccessRequired();
314  /// @private
315  bool randomReadsForced() const
316  { return myForceRandomReads; }
317 
318  /// @{
319  /// This is a tile interface for reading files. To use it, you must pass an
320  /// IMG_FileParms object to open() with IMG_FileParms::useTileInterface()
321  /// called. Otherwise, this will just return false. The x-y coords of the
322  ///tile is in pixels.
323  virtual bool readTile(const UT_InclusiveRect &tile, void *data,
324  const IMG_Plane *plane=0);
325 
326  /// this is a tile interface for writing files. To use it, you must pass an
327  /// IMG_FileParms object to open() with IMG_FileParms::useTileInterface()
328  /// called. Otherwise, this will just return false. The x-y coords of the
329  ///tile is in pixels.
330  virtual bool writeTile(const UT_InclusiveRect &tile,
331  const void *data,
332  const IMG_Plane *plane=0);
333  /// @}
334 
335  /// When writing an image, the checkpoint() method can be used to
336  /// checkpoint data (see TIFFCheckpointDirectory() for an example).
337  /// Generally, this writes the image data currently passed and this results
338  /// in a usable, partially written file.
339  /// By default, nothing is done.
340  virtual void checkpoint();
341 
342  /// This method converts the "standard" bit depth option to an IMG_DataType.
343  /// This is used by the -b option in mantra as well as many other places.
344  /// When dealing with floating point arguments, there's an optional flag to
345  /// "denormalize" the floating point values when writing. This basically
346  /// removes tiny precision errors. It's up to the user to deal with the
347  /// denormalization.
348  /// - char, byte, 8 = uint8
349  /// - short, 16 = uint16
350  /// - int = uint32
351  /// - FLOAT = fpreal32 (denormalize=true)
352  /// - HALF = fpreal16 (denormalize=true)
353  /// - float, 32 = fpreal32
354  /// - half = fpreal16
355  static IMG_DataType mapStorageOption(const char *option,
356  bool *denormalize_flag = nullptr);
357 
358  /// Turns error reporting on or off. Returns the previous setting.
359  /// Errors are reported to the error manager, which will either show up
360  /// in the node information or the Houdini status bar (if not loaded within
361  /// a node).
362  ///
363  static int doErrors( int newDoErrors );
364  static void imgError( int code, const char *msg = nullptr );
365  static void imgWarning( int code, const char *msg = nullptr );
366 
367  bool hasError() const
368  { return getBaseFile() ? (getBaseFile()->hasError() ||
369  myErrorFlag) :myErrorFlag; }
370 
371  /// Returns information about the alpha channel if the IMG_FileParms passed
372  /// to open() had detectAlphaDetails() specified.
373  virtual IMG_FileAlphaInfo getAlphaInfo(float &) const
374  { return IMG_ALPHA_VARYING; }
375 
376  /// returns the raw file at the top of the filter stack.
377  IMG_File *getUnfilteredFile();
378  const IMG_File *getUnfilteredFile() const;
379  virtual IMG_File *getBaseFile() const { return 0; }
380 
381  /// Copy the texture image options from another IMG_File
382  bool copyImageTextureOptions(const IMG_File &src,
383  bool clear_existing);
384 
385  /// Some image formats support "texture" options. Formats which do not
386  /// support options should return a NULL pointer.
387  /// This method calls @c getImageTextureOptions() by default
388  virtual UT_SharedPtr<UT_Options> imageTextureOptions() const;
389 
390  /// This method is deprecated. Please implement @c imageTextureOptions()
391  SYS_DEPRECATED(12.0) virtual const UT_Options *getImageTextureOptions() const;
392 
393  /// For image formats which support texture options, this will clear out
394  /// all texture options.
395  virtual void clearImageTextureOptions();
396 
397  /// For image formats which support texture options, merge the UT_Options
398  /// into the current options.
399  virtual bool setImageTextureOptions(const UT_Options &options);
400 
401  /// When being created through a tile device (i.e. rendering, etc.), the
402  /// writer may send additional information to the file writer after the
403  /// image has been created.
404  virtual void setWriteTag(const char *tagname,
405  int num_values,
406  const char *const *values);
407 
408  /// Read the image options (@see getOption()) to extract the world to
409  /// camera transform. If the data isn't available, this method returns
410  /// false. This will likely only work when the image is being created from
411  /// mantra.
412  bool getWorldToCamera(UT_Matrix4D &xform) const;
413 
414  /// Read the image options (@see getOption()) to extract the camera to NDC
415  /// transform. If the data isn't available in the options, this method
416  /// returns false. This will likely only work when the image is being
417  /// created from mantra.
418  /// If the @c fit_z option is true, the near/far range will be set to
419  /// (0,1). This will not be possible if the "camera:clip" setting wasn't
420  /// passed in the options.
421  bool getCameraToNDC(UT_Matrix4D &xform, int xres, int yres, bool
422  fit_z = true) const;
423  /// Read the image options (@see getOption()) to extract the world to NDC
424  /// transform. If the data isn't available in the options, this method
425  /// returns false. This will likely only work when the image is being
426  /// created from mantra.
427  /// If the @c fit_z option is true, the near/far range will be set to
428  /// (0,1). This will not be possible if the "camera:clip" setting wasn't
429  /// passed in the options.
430  bool getWorldToNDC(UT_Matrix4D &xform, int xres, int yres, bool
431  fit_z = true) const;
432 
433 
434  // API for raw deep pixel access. Methods will fail if the image is not
435  // a deep pixel image. The deep pixel functions can be accessed from
436  // multiple threads simultaneously.
437 
438  // Returns the number of deep pixel samples for the given pixel location.
439  // Returns -1 if the sample count cannot be read, or if the image is not
440  // a deep pixel image.
441  virtual int getDeepPixelSamples(int x, int y);
442 
443  // Read the deep pixel samples for the given plane. The size of the data
444  // array should be at least the same size as the number of samples returned
445  // by getDeepPixelSamples multiplied by the component count of the plane
446  // given by IMG_Plane::getComponentCount.
447  // Returns false if the data cannot be read, or if the image is not a deep
448  // pixel image.
449  virtual bool getDeepPixelPlaneData(int x, int y,
450  const IMG_Plane &plane,
451  float *data);
452 
453  // Read the deep pixel samples for all components at a given pixel location.
454  // The length of the pointer array should at least be the same as the
455  // number of samples returned from getDeepPixelSamples(). The size of
456  // each array pointed to should be at least the same size as the number
457  // of components returned from getDeepPixelComponentCount().
458  // Returns false if the data cannot be read, of if the image is not a deep
459  // pixel image.
460  virtual bool getDeepPixelData(int x, int y, float * const *data);
461 
462  /// Read a deep pixel
463  virtual bool readDeepPixelData(int x, int y,
464  PXL_DeepSampleList &pixel);
465 
466  /// @{
467  /// A method to write deep pixel data for all channels, at a given pixel
468  /// location. The function should be given an array of pointers to float
469  /// arrays, where each float array contains the value of all image
470  /// components for a given sample level.
471  ///
472  /// Returns false if the data cannot be written, or if the image is not
473  /// a deep pixel image.
474  virtual bool writeDeepPixelData(int x, int y,
475  const PXL_DeepSampleListPtr &pixel);
476  /// @}
477 
478 
479  /// users of IMG_File can select only certain planes to read using
480  /// IMG_FileParms::selectPlane..(). Call selectPlanesToRead() first,
481  /// usually at the end of open(), and then call isPlaneSelected() to
482  /// determine if the plane was selected for read.
483  /// @{
484  void selectPlanesToRead();
485  bool isPlaneSelected(const IMG_Plane &plane) const;
486  /// @}
487 
488  static void setFileCreateCB(UT_Functor1<int, const UT_StringRef &> cb);
489 
490 protected:
491  IMG_File(); /// Only called by format class
492 
493  // If the check_magic flag is 0, then the first 4 bytes of the file have
494  // alread. They are passed in as the magic number for verification.
495  virtual int open();
496  virtual int openPostMagic();
497  virtual int openFile(const char *filename);
498 
499  virtual int readScanline(int scanline, void *data) = 0;
500  virtual const void *readPlaneScanline(int y, const IMG_Plane &pi);
501 
502  // Create an image
503  virtual int createFile(const char *filename,const IMG_Stat &stat);
504  virtual int create(const IMG_Stat &stat);
505 
506  virtual int writeScanline(int scanline, const void *data) = 0;
507  virtual int writePlaneScanline(const void *data, int y,
508  const IMG_Plane &pi);
509 
510  virtual int closeFile() = 0;
511 
512  /// Run after the output stream has been closed.
513  /// Be careful, since some things have been destructed.
514  virtual void postCloseAction();
515 
516  // add any image flips, scales, data translations, etc. Returns the
517  // end of the filter chain.
518  //
519  virtual bool isPassThrough() const { return false; }
520 
521  IMG_File *makeReadFilters(const IMG_FileParms &parms);
522  IMG_File *makeWriteFilters(const IMG_FileParms &parms);
523 
524 
525  // if you override this, you must call this class's version.
526  virtual void computeCommonData();
527 
528  void *getScanlineBuffer(int y);
529  void *getPlaneBuffer(int y, const IMG_Plane &pi);
530 
531  virtual void finishedScanline(int scan);
532 
533  static void setOptions(const IMG_FileParms *options,
534  IMG_File *file);
535 
536  /// @{
537  /// Set option to control behaviour of the file. For example, the
538  /// compression level when creating the image.
539  int setOption(const char *token, const char *value);
540  int setOption(const char *token, fpreal64 val);
541  int setOption(const char *token, int64 val);
542  int setOption(const char *option, int value)
543  { return setOption(option, (int64)value); }
544  /// @}
545 
546  bool canWriteStatWithoutConversion() const;
547 
548  // Access to input and output streams
549  // peekByte() will peek at the next input byte. -1 returned on EOF
550  // readSomeBytes() will read data into the buffer specified. The number
551  // of bytes actually read is returned.
552  // writeSomeBytes() will write data from the buffer. The number
553  // of bytes actually written is returned.
554  // flushBytes() will flush the output stream
555  // readBytes() is a convenience method when all data needs to be read
556  // writeBytes() is a convenience method when all data needs to be written
557  //
558  int peekByte();
559  int readSomeBytes(void *buffer, int size);
560  int writeSomeBytes(const void *buffer, int size);
561  bool flushBytes();
562 
563  bool readBytes(void *buffer, int size)
564  { return readSomeBytes(buffer, size) == size; }
565  bool writeBytes(const void *buffer, int size)
566  { return writeSomeBytes(buffer, size) == size; }
567 
568 
569  // For the odd format which requires data to be read as ASCII lines, this
570  // method exists.
571  bool readAsciiLine(UT_WorkBuffer &wbuf);
572 
573  // Seeks the stream to the start + offset. Returns true if successful
574  // and false otherwise.
575  bool seekFromBeginning(int64 offset);
576  bool seekFromCurrent(int64 offset);
577  bool seekFromEnd(int64 offset);
578  int64 tellCurrentPosition();
579 
580  // Copies our input stream to the given stream.
581  void copyInputToStream(std::ostream &os);
582 
583  // Deletes our input stream.
584  void deleteStream();
585 
586  /////////////////////////////////////////////////////////////////////////
587  // Do not use these methods. They are for special cases only.
588  UT_IStream *getUTIStream() { return myIStream; }
589  void setIStream(UT_IStream *is) { myIStream = is; }
590  /////////////////////////////////////////////////////////////////////////
591 
592  // Image description.
595  std::ostream *myOS;
598  unsigned myCreateIStream:1,
599  myCreateOStream:1,
600  myForceRandomReads:1,
601  myHasRandomReads:1,
602  myFileOpen:1,
603  myErrorFlag:1,
604  myContinueOnErrorFlag:1;
605 
606 private:
607  class img_ScanProgress
608  {
609  public:
610  img_ScanProgress()
611  : myNumPlanes(0)
612  {
613  }
614  void init(const IMG_Stat &stat);
615  int64 getMemoryUsage(bool inclusive) const;
616  void processed(int scan, const IMG_Plane *plane);
617  void processAll(int scan);
618  bool isComplete(int scan, const IMG_Plane *plane) const;
619  bool isComplete(int scan) const;
620  int remaining(int scan) const;
621  int numScans() const { return myCounts.entries(); }
622  private:
623  int bitIndex(int scan, int plane) const;
624  private:
625  int myNumPlanes;
626  UT_BitArray myProcessed;
627  UT_ValArray<int> myCounts;
628  };
629 
630 private:
631  // Initialize tags to default values
632  void initializeTags();
633  void makeScanlineBuffers();
634  void deallocScanlineBuffer(int scan);
635  const void *returnErrorScan(int scan, const IMG_Plane &pi);
636 
637  IMG_File *makeDataConversion(const IMG_FileParms &parms,
638  IMG_File *file);
639  IMG_File *makeFlip(const IMG_FileParms &parms,
640  IMG_File *file);
641 
642 
643  static IMG_File *open(const char *filename,
644  const IMG_FileParms *options,
645  const IMG_Format *fmt,
646  const UT_Array<const IMG_Format*> *image_formats);
647 
648  const IMG_Format *myFormat;
649  IMG_FileTagList *myTagList;
650  void *myScanlineBuffer;
651  int myCurrentImageScanline;
652 
653  img_ScanProgress myScanProgress;
654  UT_ValArray<void *> myImageScanline;
655  UT_BitArray mySelectPlane;
656 
657 
658  FS_Reader *myReader;
659  FS_Writer *myWriter;
660  UT_IStream *myIStream;
661 
662  // only IMG_Format can call initializeTags().
663  friend class IMG_Format;
664  friend class IMG_FileFilter;
665  friend class IMG_GZip;
666  friend class IMG_FileBuffer;
667  friend class IMG_MemoryFileBuffer;
668  friend class MV_ReadPRISMS;
669 };
670 
671 #endif
672 
Class for reading files.
Definition: FS_Reader.h:33
const IMG_Format * getFormat() const
Definition: IMG_File.h:204
GT_API const UT_StringHolder filename
IMG_Stat myStat
Definition: IMG_File.h:593
int setOption(const char *option, int value)
Definition: IMG_File.h:542
#define SYS_DEPRECATED(__V__)
bool writeBytes(const void *buffer, int size)
Definition: IMG_File.h:565
IMG_ImageType
Type of image we want to create or have opened.
virtual IMG_File * getBaseFile() const
Definition: IMG_File.h:379
GLuint const GLchar * name
Definition: glcorearb.h:785
void close() override
GLenum src
Definition: glcorearb.h:1792
GLuint GLenum option
Definition: glew.h:3302
Describes the format and layout of a single plane in an image The plane specifies the format and name...
Definition: IMG_Plane.h:45
void read(T &in, bool &v)
Definition: ImfXdr.h:611
GLuint buffer
Definition: glcorearb.h:659
GLenum GLsizei GLsizei GLint * values
Definition: glcorearb.h:1601
GLint GLenum GLint x
Definition: glcorearb.h:408
GLsizeiptr size
Definition: glcorearb.h:663
double fpreal64
Definition: SYS_Types.h:201
#define IMG_API
Definition: IMG_API.h:10
int open(float queuesize) override
virtual const char * className() const
Definition: IMG_File.h:186
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr.
Definition: UT_SharedPtr.h:30
IMG_DataType
Definition: IMG_FileTypes.h:17
UT_IStream * getUTIStream()
Definition: IMG_File.h:588
Class for writing files.
Definition: FS_Writer.h:31
HUSD_API const char * raster()
long long int64
Definition: SYS_Types.h:116
void setIStream(UT_IStream *is)
Definition: IMG_File.h:589
bool myReadMode
Definition: IMG_File.h:594
Generic interface for reading and writing image files. This class handles the reading and writing of ...
Definition: IMG_File.h:56
bool hasError() const
Definition: IMG_File.h:367
ImageBuf OIIO_API flip(const ImageBuf &src, ROI roi={}, int nthreads=0)
GLboolean * data
Definition: glcorearb.h:130
IMG_FileAlphaInfo
GLint GLint GLsizei GLint GLenum format
Definition: glcorearb.h:107
GLuint GLfloat * val
Definition: glcorearb.h:1607
A map of string to various well defined value types.
Definition: UT_Options.h:84
std::ostream * myOS
Definition: IMG_File.h:595
Base Integer Rectangle class.
bool readBytes(void *buffer, int size)
Definition: IMG_File.h:563
void setFormat(const IMG_Format *f)
Definition: IMG_File.h:205
File options for manipulating image data on load or save. This class allows you to modify the incomin...
Definition: IMG_FileParms.h:36
GLsizei const GLfloat * value
Definition: glcorearb.h:823
GLfloat f
Definition: glcorearb.h:1925
Contains the details of a specific image file, used by IMG_File. This class contains all the high-lev...
Definition: IMG_Stat.h:40
constexpr T pi()
Pi constant taken from Boost to match old behaviour.
Definition: Math.h:118
Parameters for the saveRaster[s]AsFile[s]() methods of IMG_File.
GLintptr offset
Definition: glcorearb.h:664
#define const
Definition: zconf.h:214
void write(T &out, bool v)
Definition: ImfXdr.h:332
int64 myStreamStartPos
Definition: IMG_File.h:596
virtual IMG_FileAlphaInfo getAlphaInfo(float &) const
Definition: IMG_File.h:373
GLint y
Definition: glcorearb.h:102
int64 myStreamLength
Definition: IMG_File.h:597