auto import from //depot/cupcake/@135843
[android/platform/external/neven.git] / Embedded / common / src / b_ImageEm / UInt8Image.h
1 /*
2  * Copyright (C) 2008 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef bim_UINT8_IMAGE_EM_H
18 #define bim_UINT8_IMAGE_EM_H
19
20 /* ---- includes ----------------------------------------------------------- */
21
22 #include "b_BasicEm/Context.h"
23 #include "b_BasicEm/UInt8Arr.h"
24 #include "b_TensorEm/Int16Rect.h"
25 #include "b_TensorEm/Flt16Alt2D.h"
26
27 /* ---- related objects  --------------------------------------------------- */
28
29 /* ---- typedefs ----------------------------------------------------------- */
30
31 /* ---- constants ---------------------------------------------------------- */
32
33 /* data format version number */
34 #define bim_UINT8_IMAGE_VERSION 100
35
36 /* ---- object definition -------------------------------------------------- */
37
38 /** image of uint8 */
39 struct bim_UInt8Image 
40 {
41
42         /* ---- private data --------------------------------------------------- */
43
44         /* ---- public data ---------------------------------------------------- */
45
46         /** width of image */
47         uint32 widthE;
48
49         /** height of image */
50         uint32 heightE;
51
52         /** array of bytes */
53         struct bbs_UInt8Arr arrE;
54 };
55
56 /* ---- associated objects ------------------------------------------------- */
57
58 /* ---- external functions ------------------------------------------------- */
59
60 /* ---- \ghd{ constructor/destructor } ------------------------------------- */
61
62 /** initializes bim_UInt8Image  */
63 void bim_UInt8Image_init( struct bbs_Context* cpA,
64                                                   struct bim_UInt8Image* ptrA );
65
66 /** allocates memory for bim_UInt8Image */
67 void bim_UInt8Image_create( struct bbs_Context* cpA,
68                                                     struct bim_UInt8Image* ptrA, 
69                                                     uint32 widthA, 
70                                                         uint32 heightA,
71                                                 struct bbs_MemSeg* mspA );
72
73 /** destructor of bim_UInt8Image  */
74 void bim_UInt8Image_exit( struct bbs_Context* cpA,
75                                                   struct bim_UInt8Image* ptrA );
76
77 /* ---- \ghd{ operators } -------------------------------------------------- */
78
79 /** copy operator */
80 void bim_UInt8Image_copy( struct bbs_Context* cpA,
81                                                   struct bim_UInt8Image* ptrA, 
82                                                   const struct bim_UInt8Image* srcPtrA );
83
84 /** equal operator */
85 flag bim_UInt8Image_equal( struct bbs_Context* cpA,
86                                                    const struct bim_UInt8Image* ptrA, 
87                                                    const struct bim_UInt8Image* srcPtrA );
88
89 /* ---- \ghd{ query functions } -------------------------------------------- */
90
91 /** checksum of image (for debugging purposes) */
92 uint32 bim_UInt8Image_checkSum( struct bbs_Context* cpA,
93                                                             const struct bim_UInt8Image* ptrA );
94
95 /* ---- \ghd{ modify functions } ------------------------------------------- */
96
97 /** assigns external image to array (no allocation, deallocation or copying of data) */
98 void bim_UInt8Image_assignExternalImage( struct bbs_Context* cpA,
99                                                                                  struct bim_UInt8Image* ptrA, 
100                                                                                  struct bim_UInt8Image* srcPtrA );
101
102 /** sets image size */
103 void bim_UInt8Image_size( struct bbs_Context* cpA,
104                                                   struct bim_UInt8Image* ptrA, 
105                                                   uint32 widthA, 
106                                                   uint32 heightA );
107
108 /* ---- \ghd{ memory I/O } ------------------------------------------------- */
109
110 /** size object needs when written to memory */
111 uint32 bim_UInt8Image_memSize( struct bbs_Context* cpA,
112                                                            const struct bim_UInt8Image* ptrA );
113
114 /** writes object to memory; returns number of bytes written */
115 uint32 bim_UInt8Image_memWrite( struct bbs_Context* cpA,
116                                                             const struct bim_UInt8Image* ptrA, 
117                                                                 uint16* memPtrA );
118
119 /** reads object from memory; returns number of bytes read */
120 uint32 bim_UInt8Image_memRead( struct bbs_Context* cpA,
121                                                            struct bim_UInt8Image* ptrA, 
122                                                            const uint16* memPtrA,
123                                                    struct bbs_MemSeg* mspA );
124
125 /* ---- \ghd{ exec functions } --------------------------------------------- */
126
127 /** sets all pixels to one value */
128 void bim_UInt8Image_setAllPixels( struct bbs_Context* cpA,
129                                                                   struct bim_UInt8Image* ptrA, 
130                                                                   uint8 valueA );
131                                                         
132 /** copies a section of given image */
133 void bim_UInt8Image_copySection( struct bbs_Context* cpA,
134                                                                  struct bim_UInt8Image* ptrA, 
135                                                                  const struct bim_UInt8Image* srcPtrA, 
136                                                                  const struct bts_Int16Rect* sectionPtrA );
137
138 /** applies affine linear warping to pixels positions of imageA before copying the into *ptrA 
139  *  xOffsA, yOffsA specify an additional offset vector (16.0) that is added to image coordinates
140  */
141 void bim_UInt8Image_warpOffs( struct bbs_Context* cpA,
142                                                   struct bim_UInt8Image* ptrA, 
143                                                   const struct bim_UInt8Image* srcPtrA, 
144                                                   int32 xOffsA,
145                                                   int32 yOffsA,
146                                                   const struct bts_Flt16Alt2D* altPtrA,
147                                       int32 resultWidthA,
148                                       int32 resultHeightA );
149
150 /** applies affine linear warping to pixels positions of imageA before copying the into *ptrA */
151 void bim_UInt8Image_warp( struct bbs_Context* cpA,
152                                                   struct bim_UInt8Image* ptrA, 
153                                                   const struct bim_UInt8Image* srcPtrA, 
154                                                   const struct bts_Flt16Alt2D* altPtrA,
155                                       int32 resultWidthA,
156                                       int32 resultHeightA );
157
158 #endif /* bim_UINT8_IMAGE_EM_H */
159