HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IMG_RLEncode.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_RLEncode.h ( IMG Library, C++)
7  *
8  * COMMENTS: This class is a class which handles RLE encoding of character
9  * data. It only works on a single channel at a time, meaning
10  * that each channel in the image is encoded separately.
11  * This is the mechanism used in Vertigo, Wavefront and several
12  * other formats.
13  */
14 
15 #ifndef __IMG_RLEncode__
16 #define __IMG_RLEncode__
17 
18 #include "IMG_API.h"
19 #include <UT/UT_NonCopyable.h>
20 
21 class IMG_Plane;
22 
24 {
25 public:
26  IMG_RLEncode();
27  ~IMG_RLEncode();
28 
30 
31  // This method will return a size (in chars) which is big enough to hold
32  // any RLE scanline (in chars)
33  int bytesPerChannel(int xres);
34 
35  // This method should be called before you do any RLE encoding
36  void allocEncodeBuffer(int xres);
37 
38  // This method will rl encode the data into the buffer above. It returns
39  // the buffer and returns the length of the encoded data in
40  // "result_length". When encoding, you can skip N bytes by specifying a
41  // stride. The stride should be greater than 0 to work.
42  char *encode(const char *data, int data_length,
43  int &result_length, int stride=4);
44 
45  // This method returns 0 on failure, or the number of bytes read from the
46  // data stream.
47  int decode(char *result, int result_length, const char *data,
48  int stride=4);
49 
50  // This method will return:
51  // > 0 = repeat of first pixel_size bytes
52  // < 0 = -raw count of first pixel_size bytes
53  // For example, if the pixel_size is 1:
54  // 00000100 - will return 5 (indicating a repeat count of 5)
55  // 01010111 - will return -5 (indicating a raw run of 5)
56  static int getRepeatCount(const char *data, int pixel_size,
57  int max_run = 128, int stride=4);
58 
59  //
60  // Encode a scanline into YUV format. The stat() is used to determine the
61  // format of the rgb data as well as the length of the scanline. The YUV
62  // buffer should be at least 3*stat.getXres() bytes long.
63  // The return code is the length of the encoded YUV buffer.
64  static int yuvEncode(unsigned char *yuvdata, const void *rgbdata,
65  const IMG_Plane &plane, int xres);
66 
67  // Decode is the opposite of encode. The YUV data is decoded into the RGB
68  // data.
69  static int yuvDecode(void *rgbdata, const unsigned char *yuvdata,
70  const IMG_Plane &plane, int xres);
71 
72 private:
73  char *myData;
74 };
75 
76 #endif
**But if you need a result
Definition: thread.h:613
Describes the format and layout of a single plane in an image The plane specifies the format and name...
Definition: IMG_Plane.h:48
#define IMG_API
Definition: IMG_API.h:10
GLint GLenum GLboolean GLsizei stride
Definition: glcorearb.h:872
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
Definition: format.h:895