1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
void FI_Test(const char *bufferJpg, const int bufsizeJpg, char *bufferBmp, int *bufsizeBmp)
{
FIMEMORY *hmem = NULL;
FREE_IMAGE_FORMAT fif;
FIBITMAP *check;
BYTE *mem_buffer = NULL;
DWORD size_in_bytes = 0;
FILE *stream = NULL;
hmem = FreeImage_OpenMemory(bufferJpg, bufsizeJpg);
fif = FreeImage_GetFileTypeFromMemory(hmem, 0); // get the file type
check = FreeImage_LoadFromMemory(fif, hmem, 0); // load an image from the memory stream
FreeImage_Save(FIF_BMP, check, "blob.bmp", BMP_DEFAULT);
// le fichier blob.bmp est correctement constitué sur le disque
// save the image to a memory stream
FreeImage_SaveToMemory(FIF_BMP, check, hmem, BMP_DEFAULT);
FreeImage_AcquireMemory(hmem, &mem_buffer, &size_in_bytes);
// save the buffer to a file stream
stream = fopen("test.bmp", "wb");
if(stream) {
fwrite(mem_buffer, sizeof(BYTE), size_in_bytes, stream);
fclose(stream);
}
// close and free the memory stream
FreeImage_CloseMemory(hmem);
FreeImage_Unload(check);
} |
Partager