| 117 | #define MODULE_FUNCTION_INIT(NAME) NAME = &::NAME |
| 118 | |
| 119 | FreeImage_Module::FreeImage_Module() : module(nullptr, nullptr) { |
| 120 | // We don't care if the module loaded if we are staticly linking against |
| 121 | // FreeImage |
| 122 | ::FreeImage_Initialise(false); |
| 123 | #else |
| 124 | FreeImage_Module::FreeImage_Module() : module("freeimage", nullptr) { |
| 125 | if (!module.isLoaded()) { |
| 126 | string error_message = |
| 127 | "Error loading FreeImage: " + |
| 128 | common::DependencyModule::getErrorMessage() + |
| 129 | "\nFreeImage or one of it's dependencies failed to " |
| 130 | "load. Try installing FreeImage or check if FreeImage is in the " |
| 131 | "search path."; |
| 132 | AF_ERROR(error_message.c_str(), AF_ERR_LOAD_LIB); |
| 133 | } |
| 134 | #endif |
| 135 | MODULE_FUNCTION_INIT(FreeImage_Allocate); |
| 136 | MODULE_FUNCTION_INIT(FreeImage_AllocateT); |
| 137 | MODULE_FUNCTION_INIT(FreeImage_CloseMemory); |
| 138 | MODULE_FUNCTION_INIT(FreeImage_DeInitialise); |
| 139 | MODULE_FUNCTION_INIT(FreeImage_FIFSupportsReading); |
| 140 | MODULE_FUNCTION_INIT(FreeImage_GetBPP); |
| 141 | MODULE_FUNCTION_INIT(FreeImage_GetBits); |
| 142 | MODULE_FUNCTION_INIT(FreeImage_GetColorType); |
| 143 | MODULE_FUNCTION_INIT(FreeImage_GetFIFFromFilename); |
| 144 | MODULE_FUNCTION_INIT(FreeImage_GetFileType); |
| 145 | MODULE_FUNCTION_INIT(FreeImage_GetFileTypeFromMemory); |
| 146 | MODULE_FUNCTION_INIT(FreeImage_GetHeight); |
| 147 | MODULE_FUNCTION_INIT(FreeImage_GetImageType); |
| 148 | MODULE_FUNCTION_INIT(FreeImage_GetPitch); |
| 149 | MODULE_FUNCTION_INIT(FreeImage_GetWidth); |
| 150 | MODULE_FUNCTION_INIT(FreeImage_Initialise); |
| 151 | MODULE_FUNCTION_INIT(FreeImage_Load); |
| 152 | MODULE_FUNCTION_INIT(FreeImage_LoadFromMemory); |
| 153 | MODULE_FUNCTION_INIT(FreeImage_OpenMemory); |
| 154 | MODULE_FUNCTION_INIT(FreeImage_Save); |
| 155 | MODULE_FUNCTION_INIT(FreeImage_SaveToMemory); |
| 156 | MODULE_FUNCTION_INIT(FreeImage_SeekMemory); |
| 157 | MODULE_FUNCTION_INIT(FreeImage_SetOutputMessage); |
| 158 | MODULE_FUNCTION_INIT(FreeImage_Unload); |
| 159 | |
| 160 | #ifndef FREEIMAGE_STATIC |
| 161 | if (!module.symbolsLoaded()) { |
| 162 | string error_message = |
| 163 | "Error loading FreeImage: " + |
| 164 | common::DependencyModule::getErrorMessage() + |
| 165 | "\nThe installed version of FreeImage is not compatible with " |
| 166 | "ArrayFire. Please create an issue on which this error message"; |
| 167 | AF_ERROR(error_message.c_str(), AF_ERR_LOAD_LIB); |
| 168 | } |
| 169 | #endif |
| 170 | } |
| 171 | |
| 172 | FreeImage_Module::~FreeImage_Module() { // NOLINT(hicpp-use-equals-default, |
| 173 | // modernize-use-equals-default) |
| 174 | #ifdef FREEIMAGE_STATIC |
| 175 | getFreeImagePlugin().FreeImage_DeInitialise(); |
| 176 | #endif |
nothing calls this directly
no test coverage detected