Printing image using readimagefile, graphics.h

I am trying to print an image in c++, but I can't get it to work. Please tell me what am I missing. Where do I put my image file?
error message:
[Error] ld returned 1 exit status
recipe for target '"Graph' failed

code:

#include <graphics.h>
#include <conio.h>
#include <iostream>

int main(){

initwindow(600,500, "insert an image");
readimagefile("chi.png",0,0,500,600);

getch();
}


Which OS and Compiler are you using?

Because if it isn't "DOS" and "TurboC", the chances of making graphics.h working is minimal.

@salem c
There are more than a few modern variants of the old Borland Graphics library. It looks to me like OP is using WinBGIm.

@vaetild
I am out of state and on my mobile, so I am not going to look anything up, but IIRC, WinBGIm cannot load anything but Windows Bitmap files (.bmp). Hence the failure.

Always read the documentation. You'll have to either convert the file to .bmp or write yourself a .png reader, which isn't particularly difficult, but likely more trouble than you want.

BGI graphics are also unsuited to alpha compositing, if that is why you are trying to load a .png.

My recommendation is to ditch BGI and drive into SDL2. You will be glad you did.

Hope this helps.
Topic archived. No new replies allowed.