HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IMG_TileRead.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_TileRead.h ( IMG Library, C++)
7  *
8  * COMMENTS: This class reads tiles using the imdisplay standard pipe
9  * format. It's up to the sub-class to do anything with the data
10  * read.
11  */
12 
13 #ifndef __IMG_TileRead__
14 #define __IMG_TileRead__
15 
16 #include "IMG_API.h"
17 #include "IMG_Stat.h"
18 #include <UT/UT_NonCopyable.h>
19 
20 class PXL_Raster;
21 
23 {
24 public:
25  // flip will flip the image (i.e. y at top)
26  // keep_open will keep reading data until the "close" packet is received
27  IMG_TileRead(int flip, bool keep_open);
28  virtual ~IMG_TileRead();
29 
31 
32  // Read an image over the pipe. If there are errors reading/writing data
33  // (sub-class responsibility), this function will return 0 (and do an early
34  // abort).
35  int readImage();
36 
37 protected:
38  // Return the number of elements read.
39  // Return <= 0 if failed
40  virtual int readData(void *data, int size, int nelem) = 0;
41 
42  virtual int openWrite() = 0;
43  virtual int writeTile(int tx0, int tx1, int ty0, int ty1,
44  const void *data, int plane = 0) = 0;
45  virtual int closeWrite() = 0;
46 
47  //
48  // Error messages can be printed out by providing this method (default is
49  // to do nothing)
50  virtual void error(const char *message);
51 
52  // Convenience function to write the data into an IMG_Raster class
53  void writeTileToRaster(PXL_Raster &raster,
54  int tx0, int tx1, int ty0, int ty1,
55  const void *data, int plane);
56 
57  // Find out information about image being read. This will be defined by
58  // the time openWrite() is called (but not before readData() is called the
59  // first time.
60  const IMG_Stat &getStat() const { return myStat; }
61 
62 private:
63  void setPlaneFormat(int format, int asize,
64  IMG_DataType &dtype,
65  IMG_ColorModel &cmodel);
66  void growData(int bytes);
67  void *myData;
68  int myPoolSize;
69  int mySwab; // Swap bytes
70  int myFlip; // Flip vertically
71  IMG_Stat myStat;
72  bool myKeepOpen;
73 };
74 
75 #endif
GLuint GLsizei const GLchar * message
Definition: glcorearb.h:2543
< returns > If no error
Definition: snippets.dox:2
void readData(std::istream &is, T *data, Index count, uint32_t compression, DelayedLoadMetadata *metadata=nullptr, size_t metadataOffset=size_t(0))
Read data from a stream.
Definition: Compression.h:247
#define IMG_API
Definition: IMG_API.h:10
IMG_DataType
Definition: IMG_FileTypes.h:17
GLint GLint GLsizei GLint GLenum format
Definition: glcorearb.h:108
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
HUSD_API const char * raster()
ImageBuf OIIO_API flip(const ImageBuf &src, ROI roi={}, int nthreads=0)
GLsizeiptr size
Definition: glcorearb.h:664
const IMG_Stat & getStat() const
Definition: IMG_TileRead.h:60
IMG_ColorModel
Definition: IMG_FileTypes.h:52
Contains the details of a specific image file, used by IMG_File. This class contains all the high-lev...
Definition: IMG_Stat.h:38
Definition: format.h:895
Definition: format.h:2459