• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_UINT16_PYR_IMAGE_EM_H
18 #define bim_UINT16_PYR_IMAGE_EM_H
19 
20 /* ---- includes ----------------------------------------------------------- */
21 
22 #include "b_BasicEm/Context.h"
23 #include "b_ImageEm/UInt16ByteImage.h"
24 
25 /* ---- related objects  --------------------------------------------------- */
26 
27 /* ---- typedefs ----------------------------------------------------------- */
28 
29 #define bim_PYRAMIDAL_IMAGE_STANDARD_DEPTH 4
30 
31 /* ---- constants ---------------------------------------------------------- */
32 
33 /* data format version number */
34 #define bim_UINT16_PYRAMIDAL_IMAGE_VERSION 100
35 
36 /* ---- object definition -------------------------------------------------- */
37 
38 /** Pyramidal image of uint16 (packed bytes).
39  *
40  *  2 pixels are stored in one 16-bit word. On a little endian system the
41  *  image data of bim_UInt16BytePyrImage and bim_UInt8PyramidalImage have
42  *  an identical memory representation.
43  *
44  *  The Pyramidal format is as follows:
45  *  widthE  specifies width of first image (image 0)
46  *  heightE specifies height of first image (image 0)
47  *  depthE  specifies the number of levels present
48  *  image n has half of the width,heigth nimension of image n-1
49  *  A pixel of in image n is the average of the corresponding 4
50  *  covering pixels in image n-1
51  *  Adresses of data relative to arrE.arrPtrE
52  *  The address of image 0 is 0
53  *  The address of image 1 is widthE * heightE / 2
54  *  The address of image n is widthE * heightE / 2 + widthE * heightE / 8 + ... + widthE * heightE * ( 2^-(2*n) )
55  *  Use function uint16* bim_UInt16BytePyrImage_arrPtr( uint32 levelA ) to obtain adress of image at given depth level
56  *  Use function bim_UInt16BytePyrImage_importUInt8 to create a pyramidal image from an uint8 image
57 */
58 struct bim_UInt16BytePyrImage
59 {
60 	/** width of image */
61 	uint32 widthE;
62 
63 	/** height of image */
64 	uint32 heightE;
65 
66 	/** depth of image (number of layers) */
67 	uint32 depthE;
68 
69 	/** pyramidal image type (temporary: until switch to 16-bit complete) */
70 	uint32 typeE;
71 
72 	/** array of bytes */
73 	struct bbs_UInt16Arr arrE;
74 };
75 
76 /* ---- external functions ------------------------------------------------- */
77 
78 /* ---- \ghd{ constructor/destructor } ------------------------------------- */
79 
80 /** initializes bim_UInt16BytePyrImage  */
81 void bim_UInt16BytePyrImage_init( struct bbs_Context* cpA,
82 								  struct bim_UInt16BytePyrImage* ptrA );
83 
84 /** allocates memory for bim_UInt16BytePyrImage  */
85 void bim_UInt16BytePyrImage_create( struct bbs_Context* cpA,
86 								    struct bim_UInt16BytePyrImage* ptrA,
87 									 uint32 widthA, uint32 heightA,
88 									 uint32 depthA,
89  									 struct bbs_MemSeg* mspA );
90 
91 /** frees bim_UInt16BytePyrImage  */
92 void bim_UInt16BytePyrImage_exit( struct bbs_Context* cpA,
93 								  struct bim_UInt16BytePyrImage* ptrA );
94 
95 /* ---- \ghd{ operators } -------------------------------------------------- */
96 
97 /** copy operator */
98 void bim_UInt16BytePyrImage_copy( struct bbs_Context* cpA,
99 								  struct bim_UInt16BytePyrImage* ptrA,
100 								  const struct bim_UInt16BytePyrImage* srcPtrA );
101 
102 /** equal operator */
103 flag bim_UInt16BytePyrImage_equal( struct bbs_Context* cpA,
104 								   const struct bim_UInt16BytePyrImage* ptrA,
105 								   const struct bim_UInt16BytePyrImage* srcPtrA );
106 
107 /* ---- \ghd{ query functions } -------------------------------------------- */
108 
109 /** returns adress of image at given depth level */
110 uint16* bim_UInt16BytePyrImage_arrPtr( struct bbs_Context* cpA,
111 									   const struct bim_UInt16BytePyrImage* ptrA,
112 									   uint32 levelA );
113 
114 /** calculates the amount of heap memory needed (16bit words) if created with given parameters */
115 uint32 bim_UInt16BytePyrImage_heapSize( struct bbs_Context* cpA,
116 									    const struct bim_UInt16BytePyrImage* ptrA,
117 										uint32 widthA,
118 										uint32 heightA,
119 										uint32 depthA );
120 
121 /* ---- \ghd{ modify functions } ------------------------------------------- */
122 
123 /** sets image size */
124 void bim_UInt16BytePyrImage_size( struct bbs_Context* cpA,
125 								  struct bim_UInt16BytePyrImage* ptrA,
126 								  uint32 widthA,
127 								  uint32 heightA,
128 								  uint32 depthA );
129 
130 /* ---- \ghd{ memory I/O } ------------------------------------------------- */
131 
132 /** size object needs when written to memory */
133 uint32 bim_UInt16BytePyrImage_memSize( struct bbs_Context* cpA,
134 									   const struct bim_UInt16BytePyrImage* ptrA );
135 
136 /** writes object to memory; returns number of words (16-bit) written */
137 uint32 bim_UInt16BytePyrImage_memWrite( struct bbs_Context* cpA,
138 									    const struct bim_UInt16BytePyrImage* ptrA,
139 										uint16* memPtrA );
140 
141 /** reads object from memory; returns number of words (16-bit) read */
142 uint32 bim_UInt16BytePyrImage_memRead( struct bbs_Context* cpA,
143 									   struct bim_UInt16BytePyrImage* ptrA,
144 									    const uint16* memPtrA,
145  									    struct bbs_MemSeg* mspA );
146 
147 /* ---- \ghd{ exec functions } --------------------------------------------- */
148 
149 /** create overlay bim_Uint16Image (does not own memory) */
150 void bim_UInt16BytePyrImage_overlayUInt16( struct bbs_Context* cpA,
151 										   const struct bim_UInt16BytePyrImage* ptrA,
152 											 struct bim_UInt16ByteImage* uint16ImageA );
153 
154 /** recompute pyramidal format with given depth from data in layer 0 */
155 void bim_UInt16BytePyrImage_recompute( struct bbs_Context* cpA,
156 									   struct bim_UInt16BytePyrImage* dstPtrA );
157 
158 /** import uint8image and creates pyramidal format with given depth */
159 void bim_UInt16BytePyrImage_importUInt16( struct bbs_Context* cpA,
160 										  struct bim_UInt16BytePyrImage* dstPtrA,
161 											const struct bim_UInt16ByteImage* srcPtrA,
162 											uint32 depthA );
163 
164 #endif /* bim_UINT16_PYR_IMAGE_EM_H */
165 
166