0

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
Christian Stewart
  • 15,217
  • 20
  • 82
  • 139
  • See docs for `FreeImage_SetOutputMessage` and use it, maybe you will get an error message. Also you might be missing a call to `FreeImage_Initialise`. – user2802841 Mar 06 '14 at 23:31

2 Answers2

0

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

user2802841
  • 903
  • 7
  • 13
0

Sometimes freeimage doesntmanage to read the FREE_IMAGE_FORMAT from FreeImage_GetFileType

so it is recomended to check the validity of fif and if fif == FIF_UNKNOWN use FreeImage_GetFIFFromFilename

Frank Escobar
  • 368
  • 4
  • 20