| 1037 | } |
| 1038 | |
| 1039 | af_err af_delete_image_memory(void* ptr) { |
| 1040 | try { |
| 1041 | ARG_ASSERT(0, ptr != NULL); |
| 1042 | |
| 1043 | FreeImage_Module& _ = getFreeImagePlugin(); |
| 1044 | |
| 1045 | // set your own FreeImage error handler |
| 1046 | _.FreeImage_SetOutputMessage(FreeImageErrorHandler); |
| 1047 | |
| 1048 | auto* stream = static_cast<FIMEMORY*>(ptr); |
| 1049 | _.FreeImage_SeekMemory(stream, 0L, SEEK_SET); |
| 1050 | |
| 1051 | // Ensure data is freeimage compatible |
| 1052 | FREE_IMAGE_FORMAT fif = |
| 1053 | _.FreeImage_GetFileTypeFromMemory(static_cast<FIMEMORY*>(ptr), 0); |
| 1054 | if (fif == FIF_UNKNOWN) { |
| 1055 | AF_ERROR("FreeImage Error: Unknown Filetype", AF_ERR_NOT_SUPPORTED); |
| 1056 | } |
| 1057 | |
| 1058 | _.FreeImage_CloseMemory(static_cast<FIMEMORY*>(ptr)); |
| 1059 | } |
| 1060 | CATCHALL; |
| 1061 | |
| 1062 | return AF_SUCCESS; |
| 1063 | } |
| 1064 | |
| 1065 | #else // WITH_FREEIMAGE |
| 1066 | #include <common/err_common.hpp> |