c++freeimage

FreeImage zero width and height


I'm trying to load a .png and a .DDS file in FreeImage, but the width and height are always zero.

#include <stdio.h>
#include<stdlib.h>

#include <FreeImage.h>

int main(void){
  const char* path = "Signal.png";
  printf("Loading image %s\n", path);
  FIBITMAP* image = FreeImage_Load(FreeImage_GetFileType(path), path, 0);
  unsigned int w = FreeImage_GetWidth(image);
  unsigned int h = FreeImage_GetHeight(image);
  printf("Width: %u Height: %u\n", w, h);

}

Output:

Loading image Signal.png
Width: 0 Height: 0

Solution

  • You might be missing a call to FreeImage_Initialise (unless you are using a DLL).