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_COMPLEX_IMAGE_EM_H 18#define bim_COMPLEX_IMAGE_EM_H 19 20/* ---- includes ----------------------------------------------------------- */ 21 22#include "b_BasicEm/Context.h" 23#include "b_BasicEm/ComplexArr.h" 24#include "b_TensorEm/Int16Rect.h" 25#include "b_TensorEm/Flt16Alt2D.h" 26 27/* ---- related objects --------------------------------------------------- */ 28 29struct bim_APhImage; 30 31/* ---- typedefs ----------------------------------------------------------- */ 32 33/* ---- constants ---------------------------------------------------------- */ 34 35/* data format version number */ 36#define bim_COMPLEX_IMAGE_VERSION 100 37 38/* ---- object definition -------------------------------------------------- */ 39 40/** image of complex values */ 41struct bim_ComplexImage 42{ 43 44 /* ---- private data --------------------------------------------------- */ 45 46 /* ---- public data ---------------------------------------------------- */ 47 48 /** width of image */ 49 uint32 widthE; 50 51 /** height of image */ 52 uint32 heightE; 53 54 /** array of bytes */ 55 struct bbs_ComplexArr arrE; 56}; 57 58/* ---- associated objects ------------------------------------------------- */ 59 60/* ---- external functions ------------------------------------------------- */ 61 62/* ---- \ghd{ constructor/destructor } ------------------------------------- */ 63 64/** initializes bim_ComplexImage */ 65void bim_ComplexImage_init( struct bbs_Context* cpA, 66 struct bim_ComplexImage* ptrA ); 67 68/** frees bim_ComplexImage */ 69void bim_ComplexImage_exit( struct bbs_Context* cpA, 70 struct bim_ComplexImage* ptrA ); 71 72/* ---- \ghd{ operators } -------------------------------------------------- */ 73 74/** copy operator */ 75void bim_ComplexImage_copy( struct bbs_Context* cpA, 76 struct bim_ComplexImage* ptrA, 77 const struct bim_ComplexImage* srcPtrA ); 78 79/** equal operator */ 80flag bim_ComplexImage_equal( struct bbs_Context* cpA, 81 const struct bim_ComplexImage* ptrA, 82 const struct bim_ComplexImage* srcPtrA ); 83 84/* ---- \ghd{ query functions } -------------------------------------------- */ 85 86/** checksum of image (for debugging purposes) */ 87uint32 bim_ComplexImage_checkSum( struct bbs_Context* cpA, 88 const struct bim_ComplexImage* ptrA ); 89 90/** calculates the amount of heap memory needed (16bit words) if created with given parameters */ 91uint32 bim_ComplexImage_heapSize( struct bbs_Context* cpA, 92 const struct bim_ComplexImage* ptrA, 93 uint32 widthA, uint32 heightA ); 94 95/* ---- \ghd{ modify functions } ------------------------------------------- */ 96 97/** allocates memory for bim_ComplexImage */ 98void bim_ComplexImage_create( struct bbs_Context* cpA, 99 struct bim_ComplexImage* ptrA, 100 uint32 widthA, 101 uint32 heightA, 102 struct bbs_MemSeg* mspA ); 103 104/** sets image size */ 105void bim_ComplexImage_size( struct bbs_Context* cpA, 106 struct bim_ComplexImage* ptrA, 107 uint32 widthA, 108 uint32 heightA ); 109 110/* ---- \ghd{ memory I/O } ------------------------------------------------- */ 111 112/** word size (16-bit) object needs when written to memory */ 113uint32 bim_ComplexImage_memSize( struct bbs_Context* cpA, 114 const struct bim_ComplexImage* ptrA ); 115 116/** writes object to memory; returns number of words (16-bit) written */ 117uint32 bim_ComplexImage_memWrite( struct bbs_Context* cpA, 118 const struct bim_ComplexImage* ptrA, 119 uint16* memPtrA ); 120 121/** reads object from memory; returns number of words (16-bit) read */ 122uint32 bim_ComplexImage_memRead( struct bbs_Context* cpA, 123 struct bim_ComplexImage* ptrA, 124 const uint16* memPtrA, 125 struct bbs_MemSeg* mspA ); 126 127/* ---- \ghd{ exec functions } --------------------------------------------- */ 128 129/** sets all pixels to one value */ 130void bim_ComplexImage_setAllPixels( struct bbs_Context* cpA, 131 struct bim_ComplexImage* ptrA, 132 struct bbs_Complex valueA ); 133 134/** copies a section of given image */ 135void bim_ComplexImage_copySection( struct bbs_Context* cpA, 136 struct bim_ComplexImage* ptrA, 137 const struct bim_ComplexImage* srcPtrA, 138 const struct bts_Int16Rect* sectionPtrA ); 139 140/** import abs-phase image */ 141void bim_ComplexImage_importAPh( struct bbs_Context* cpA, 142 struct bim_ComplexImage* dstPtrA, 143 const struct bim_APhImage* srcPtrA ); 144 145#endif /* bim_COMPLEX_IMAGE_EM_H */ 146 147