#include<graphics.h>
#include<conio.h>
#include<stdlib.h>
#include<dos.h>
#include<alloc.h>
main()
{
int gd = DETECT, gm, area, temp1, temp2, left = 25, top = 75;
void far *p;
initgraph(&gd,&gm,"C:\\TurboC3\\BGI");
rectangle(25,75,100,100);
int sz=imagesize(25,75,100,100);
p=farmalloc(sz);
getch();
temp1 = 200;
temp2 = 200;
getimage(left, top, left + 100, top + 100, p);
putimage(left, top, p, XOR_PUT);
getch();
putimage(temp1 , temp2, p, XOR_PUT);
getch();
closegraph();
return 0;
}
whenever I execute the above code the compiler stucks and windows hangs. I don't know how to use getimage()
and putimage()
properly . I want to design tetris in c so first getting hands on these functions
You have not allocated enough memory for the image, with
I suggest using this to get the image size
which uses the same parameters as
getimage()
.