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 class PXL_Raster;
19 
21 {
22 public:
23  // flip will flip the image (i.e. y at top)
24  // keep_open will keep reading data until the "close" packet is received
25  IMG_TileRead(int flip, bool keep_open);
26  virtual ~IMG_TileRead();
27 
28  // Read an image over the pipe. If there are errors reading/writing data
29  // (sub-class responsibility), this function will return 0 (and do an early
30  // abort).
31  int readImage();
32 
33 protected:
34  // Return the number of elements read.
35  // Return <= 0 if failed
36  virtual int readData(void *data, int size, int nelem) = 0;
37 
38  virtual int openWrite() = 0;
39  virtual int writeTile(int tx0, int tx1, int ty0, int ty1,
40  const void *data, int plane = 0) = 0;
41  virtual int closeWrite() = 0;
42 
43  //
44  // Error messages can be printed out by providing this method (default is
45  // to do nothing)
46  virtual void error(const char *message);
47 
48  // Convenience function to write the data into an IMG_Raster class
49  void writeTileToRaster(PXL_Raster &raster,
50  int tx0, int tx1, int ty0, int ty1,
51  const void *data, int plane);
52 
53  // Find out information about image being read. This will be defined by
54  // the time openWrite() is called (but not before readData() is called the
55  // first time.
56  const IMG_Stat &getStat() const { return myStat; }
57 
58 private:
59  void setPlaneFormat(int format, int asize,
60  IMG_DataType &dtype,
61  IMG_ColorModel &cmodel);
62  void growData(int bytes);
63  void *myData;
64  int myPoolSize;
65  int mySwab; // Swap bytes
66  int myFlip; // Flip vertically
67  IMG_Stat myStat;
68  bool myKeepOpen;
69 };
70 
71 #endif
GLsizeiptr size
Definition: glcorearb.h:663
#define IMG_API
Definition: IMG_API.h:10
IMG_DataType
Definition: IMG_FileTypes.h:17
GLboolean * data
Definition: glcorearb.h:130
GLuint GLsizei const GLchar * message
Definition: glcorearb.h:2542
GLint GLint GLsizei GLint GLenum format
Definition: glcorearb.h:107
const IMG_Stat & getStat() const
Definition: IMG_TileRead.h:56
IMG_ColorModel
Definition: IMG_FileTypes.h:53
Contains the details of a specific image file, used by IMG_File. This class contains all the high-lev...
Definition: IMG_Stat.h:40
void readData(std::istream &is, T *data, Index count, uint32_t compression)
Read data from a stream.
Definition: Compression.h:179