freeimage.h

FreeImage_UnlockPage

DLL_API void DLL_CALLCONV FreeImage_UnlockPage(FIMULTIBITMAP *bitmap, FIBITMAP *data,
BOOL changed);

Desbloquea una página previamente bloqueada y la devuelve al motos multipágina. Cuando el último parámetro es TRUE, la página es marcada como modificada y los nuevos datos de página son aplicados al mapa de bits multipágina.

bool CloneMultiPage(FREE_IMAGE_FORMAT fif, char *input, char *output, int output_flag)
{
    BOOL bMemoryCache = TRUE;
    // Open src file (read-only, use memory cache)
    FIMULTIBITMAP *src = FreeImage_OpenMultiBitmap(fif, input, FALSE, TRUE,
        bMemoryCache);
    if(src) {
        // Open dst file (creation, use memory cache)
        FIMULTIBITMAP *dst = FreeImage_OpenMultiBitmap(fif, output, TRUE, FALSE,
            bMemoryCache);
        // Get src page count
        int count = FreeImage_GetPageCount(src);
        // Clone src to dst
        for(int page = 0; page < count; page++) {
            // Load the bitmap at position 'page'
            FIBITMAP *dib = FreeImage_LockPage(src, page);
            if(dib) {
                // add a new bitmap to dst
                FreeImage_AppendPage(dst, dib);
                // Unload the bitmap (do not apply any change to src)
                FreeImage_UnlockPage(src, dib, FALSE);
            }
        }
        // Close src
        FreeImage_CloseMultiBitmap(src, 0);
        // Save and close dst
        FreeImage_CloseMultiBitmap(dst, output_flag);
        return true;
    }
    return false;
}