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 class IMG_Plane;
20 
22 public:
23  IMG_RLEncode();
24  ~IMG_RLEncode();
25 
26  // This method will return a size (in chars) which is big enough to hold
27  // any RLE scanline (in chars)
28  int bytesPerChannel(int xres);
29 
30  // This method should be called before you do any RLE encoding
31  void allocEncodeBuffer(int xres);
32 
33  // This method will rl encode the data into the buffer above. It returns
34  // the buffer and returns the length of the encoded data in
35  // "result_length". When encoding, you can skip N bytes by specifying a
36  // stride. The stride should be greater than 0 to work.
37  char *encode(const char *data, int data_length,
38  int &result_length, int stride=4);
39 
40  // This method returns 0 on failure, or the number of bytes read from the
41  // data stream.
42  int decode(char *result, int result_length, const char *data,
43  int stride=4);
44 
45  // This method will return:
46  // > 0 = repeat of first pixel_size bytes
47  // < 0 = -raw count of first pixel_size bytes
48  // For example, if the pixel_size is 1:
49  // 00000100 - will return 5 (indicating a repeat count of 5)
50  // 01010111 - will return -5 (indicating a raw run of 5)
51  static int getRepeatCount(const char *data, int pixel_size,
52  int max_run = 128, int stride=4);
53 
54  //
55  // Encode a scanline into YUV format. The stat() is used to determine the
56  // format of the rgb data as well as the length of the scanline. The YUV
57  // buffer should be at least 3*stat.getXres() bytes long.
58  // The return code is the length of the encoded YUV buffer.
59  static int yuvEncode(unsigned char *yuvdata, const void *rgbdata,
60  const IMG_Plane &plane, int xres);
61 
62  // Decode is the opposite of encode. The YUV data is decoded into the RGB
63  // data.
64  static int yuvDecode(void *rgbdata, const unsigned char *yuvdata,
65  const IMG_Plane &plane, int xres);
66 
67 private:
68  char *myData;
69 };
70 
71 #endif
Describes the format and layout of a single plane in an image The plane specifies the format and name...
Definition: IMG_Plane.h:44
#define IMG_API
Definition: IMG_API.h:10
GLint GLenum GLboolean GLsizei stride
Definition: glcorearb.h:871
GLboolean * data
Definition: glcorearb.h:130