图形函数问题,好像通过COPY_PUT后,原来的图形还在,怎么处理?

huyunkun 2003-10-19 06:00:00
我原来是准备做一个简单的动画(建设初期),可是,在运行这个半成品的时候,去发现原来的那个图形在putimage之后还是存在?不知道为什么,我也看过很一些源代码,却没有这个问题。
帮忙解决一下,问题部分我在后面附注了:
源代码如下:
#include <stdio.h>
#include <conio.h>
#include <graphics.h>
#include <string.h>
#include <dos.h>

main()
{ int gdriver,gmode,ierror;
char str1[100],str2[100],str3[100];
strcpy(str1,"The Route of The Emanant Missile");
strcpy(str2,"Please press any key to continue...");
strcpy(str3,"Press any key to Exit...");
gdriver=VGA;
gmode=2;
initgraph(&gdriver,&gmode,"");
ierror=graphresult();
if(ierror!=0)
{printf("graphics error: %s\n",grapherrormsg(ierror));
printf("Please any key to halt.");
getch();
exit(1);
}
setbkcolor(0);
setbkcolor(1);
cleardevice();
setcolor(14);
setlinestyle(2,0,4);
rectangle(0,0,getmaxx(),479);
getch();
settextstyle(0,0,1);
outtextxy(0,15,str1);
setcolor(11);
line(0,29,639,29);
line(0,479-20,639,479-20);
settextstyle(0,0,0);
outtextxy(0,464,str2);
setviewport(0,29,639,469,0);
interface();
getch();
start();
getch();
closegraph();
}

interface()
{ rectangle(20,430-20,80,430);
rectangle(30,430-25,70,430-20);
line(20+25,430-25,20+34,430-51);
line(20+35,430-25,20+44,430-51);
line(20+34,430-51,20+44,430-51);
rectangle(500,430-20,540,430);
settextstyle(0,0,1);
setfillstyle(11,12);
floodfill(21,430-19,11);
floodfill(501,430-15,11);
outtextxy(80,420,"launch pad");
outtextxy(542,420,"enemy");
}

start()
{char *w;
int i;
setfillstyle(1,8);
pieslice(20+39+3,430-51-6,0,360,5);
w=malloc(imagesize(20+39+3-5,430-57-6,20+39+3+5,430-57-5));
getimage(57,430-62,67,430-52,w);
for(i=0;i<=400;i++)/*这里出问题了*/
{putimage(58+i,430-62,w,1);
}
}
...全文
49 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
huyunkun 2003-10-22
  • 打赏
  • 举报
回复
其实两位误解了我的意思,因为经过putimage(58+i,430-62,w,0之后,会留下红色的轨迹。我的意思是怎样去解决这个问题。
我现在自己解决了。
可以提供给csdn上的朋友们参考一下:
在putimage(58+i,430-62,w,0)之后加入语句putimage(58+i,430-62,w,1),就可以了。
可以直接出现你想要的结果。。
limd 2003-10-20
  • 打赏
  • 举报
回复
楼上对
daizh 2003-10-19
  • 打赏
  • 举报
回复
putimage(58+i,430-62,w,1);中的参数规定如何释放内存中图像方法用错,应该用COPY_PUT(0复制)而不是XOR_PUT(1与屏幕图像异或的复制),即putimage(58+i,430-62,w,0);

24,854

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 工具平台和程序库
社区管理员
  • 工具平台和程序库社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧