سؤال

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
هل كانت مفيدة؟

المحلول

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

نصائح أخرى

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top