Andre Ahmed
Andre Ahmed

Reputation: 1889

converting float image to int64 and use it in FreeImage

I have a raw 64bit Float binary file, and would like to use FreeImage to tonemapp it. What I have read in the docs that it has that function FreeImage_ConvertFromRawBits So first I should convert it to FreeImage Type from memory, but that function doesn't support 64Bit float images..? Then after that I should tonemap it.. What's the correct approach to tonemap a raw 64bit float ?

Docs is here: https://mirrors.dotsrc.org/exherbo/FreeImage3170.pdf

What I get is a scannled lined distored image Here is the input file: https://www.mediafire.com/file/ffv6qzvpg05xaja/15_init_image.bin/file

enter image description here Here is my attempt ?

#include <iostream>
#include <stdlib.h>
#include <fstream>
#include <vector>
#include "FreeImage.h"

int main()
{

    std::ifstream stream("c:/output/15_init_image.bin", std::ios::in | std::ios::binary);
    std::vector<uint8_t> contents((std::istreambuf_iterator<char>(stream)), std::istreambuf_iterator<char>());

    int width = 2048; // get the width of the image ;
    int height = 3096; // get the height of the image ;
    int bpp = 32;
    FreeImage_Initialise();
    int pitch = 512;

    FIBITMAP* src = FreeImage_ConvertFromRawBitsEx(true, contents.data(), FIT_BITMAP, width, height, pitch, FI_RGBA_RED_MASK,
        FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK, FALSE);
    FreeImage_Save(FIF_JPEG, src, "viewport.jpeg");

    
    return 0;

}

Upvotes: 0

Views: 146

Answers (0)

Related Questions