00001 #include <stdio.h> 00002 #include "vapiTypes.h" 00003 #include "vapiOperationOptions.h" 00004 #include "vapiAux.h" 00005 #include "vapiImages.h" 00006 #include "vapiImagesAux.h" 00007 #include "vapiMemory.h" 00008 #include "vapiOptions.h" 00009 00010 vOptions * 00011 vapiOperationOptionsInit (vEffect * Operation) 00012 { 00013 vOptions *Options; 00014 vEffectOptions *CustomOptions; 00015 vEffectSettings *OperationSettings; 00016 00017 /* 00018 * Pequena verificação de segurança. 00019 */ 00020 if (Operation == NULL) 00021 { 00022 return NULL; 00023 } 00024 CustomOptions = 00025 malloc (sizeof (vEffectOptions)); 00026 OperationSettings = 00027 Operation->OptionsSettings->CustomOptionsSettings; 00028 Options = vapiOptionsInit (Operation->OptionsSettings); 00029 Options->CustomOptions = CustomOptions; 00030 00031 CustomOptions->original = vFALSE; 00032 CustomOptions->times = 1; 00033 00034 if (OperationSettings->NeedOfAuxImage == NeedTemplate 00035 || OperationSettings->NeedOfAuxImage == NeedRegion) 00036 { 00037 CustomOptions->Template = NULL; 00038 } 00039 00040 return Options; 00041 } 00042 00043 void 00044 vapiCheckOptOriginal (vImages * Images, vOptions * Options) 00045 { 00046 if (((vEffectOptions *) Options->CustomOptions)->original) 00047 { 00048 vImagesFreeActual (Images); 00049 vapiOriginal2Actual (Images); 00050 } 00051 } 00052 00053 void 00054 vEffectOptionsFree (vOptions * Options, vOptionsSettings * OptionsSettings) 00055 { 00056 vEffectSettings *OperationSettings = 00057 OptionsSettings->CustomOptionsSettings; 00058 00059 if (OperationSettings->NeedOfAuxImage != NoNeed) 00060 { 00061 vOptionsFreeTemplate (Options); 00062 } 00063 free (Options->CustomOptions); 00064 } 00065 00066 void 00067 vOptionsFreeTemplate (vOptions * options) 00068 { 00069 if (! 00070 (((vEffectOptions *) options->CustomOptions)->Template == 00071 NULL)) 00072 { 00073 cvReleaseImage (& 00074 ((vEffectOptions *) options-> 00075 CustomOptions)->Template); 00076 00077 } 00078 } 00079 00080 00081 vOptions * 00082 vapiOptionsCopy (vEffect * Operation, vOptions * Options) 00083 { 00084 vOptions *Options2; 00085 int i; 00086 00087 Options2 = vapiOperationOptionsInit (Operation); 00088 00089 /* 00090 * Pequena verificação de segurança. 00091 */ 00092 if (Operation == NULL) 00093 { 00094 return NULL; 00095 } 00096 ((vEffectOptions *) Options2)->original = 00097 ((vEffectOptions *) Options)->original; 00098 ((vEffectOptions *) Options2)->times = 00099 ((vEffectOptions *) Options)->times; 00100 00101 /* 00102 * Definição e alocação de espaço de acordo com as necessidades da operação. 00103 */ 00104 if (Operation->OptionsSettings->floatsNumber) 00105 { 00106 for (i = 0; i < Operation->OptionsSettings->floatsNumber; i++) 00107 { 00108 Options2->floats[i] = Options2->floats[i]; 00109 } 00110 } 00111 if (Operation->OptionsSettings->intsNumber) 00112 { 00113 00114 for (i = 0; i < Operation->OptionsSettings->intsNumber; i++) 00115 { 00116 Options2->ints[i] = Options->ints[i]; 00117 } 00118 } 00119 00120 if (Operation->OptionsSettings->charsNumber) 00121 { 00122 for (i = 0; i < Operation->OptionsSettings->charsNumber; i++) 00123 { 00124 Options2->chars[i].ch = 00125 vapiReturnStringPointer (Options->chars[i]. 00126 ch); 00127 } 00128 } 00129 if (Operation->OptionsSettings->chooseNumber) 00130 { 00131 00132 for (i = 0; i < Operation->OptionsSettings->chooseNumber; i++) 00133 { 00134 Options2->choices[i] = Options->choices[i]; 00135 } 00136 } 00137 if (Operation->OptionsSettings->booleansNumber) 00138 { 00139 00140 for (i = 0; i < Operation->OptionsSettings->booleansNumber; 00141 i++) 00142 { 00143 Options2->booleans[i] = Options->booleans[i]; 00144 } 00145 } 00146 if (((vEffectSettings *) Operation->OptionsSettings-> 00147 CustomOptionsSettings)->NeedOfAuxImage == NeedTemplate 00148 || ((vEffectSettings *) Operation->OptionsSettings-> 00149 CustomOptionsSettings)->NeedOfAuxImage == NeedRegion) 00150 { 00151 ((vEffectOptions *) Options2)->Template = 00152 ((vEffectOptions *) Options)->Template; 00153 } 00154 00155 return Options2; 00156 00157 } 00158 00159 void 00160 vOperationOptionsFree (vOptions * Options, vEffect * Operation) 00161 { 00162 vOptionsFree (Options, Operation->OptionsSettings, 00163 &vEffectOptionsFree); 00164 } 00165 00166 IplImage * 00167 vapiOptionsGetTemplate (vOptions * Options) 00168 { 00169 vEffectOptions * OperationOptions = Options->CustomOptions; 00170 00171 return OperationOptions->Template; 00172 }