c语言自己写图形函数 c语言自己写图形函数怎么做( 二 )


exit(-1);
}
return 0;
}
/*
创建屏幕 , 并将屏幕设置为640x480大小
*/
SDL_Surface *createScreen(int width,int height,int bpp,Uint32 flags)
{
SDL_Surface *screen;
if((screen = SDL_SetVideoMode(width,height,bpp,flags))==NULL)
{
fprintf(stderr,"Could not create a screen:%s\n",SDL_GetError());
exit(-1);
}
return screen;
}
/*
加载图片
*/
void loadImage(char *filename,SDL_Surface *screen,int xPos,int yPos)
{
SDL_Surface *image;
SDL_Rect dest;
image = SDL_LoadBMP(filename);
if ( image == NULL ){
fprintf(stderr, "无法加载 %s: %s\n", filename, SDL_GetError());
exit(-1);
}
dest.x = xPos;
dest.y = yPos;
dest.w = image-w;
dest.h = image-h;
SDL_BlitSurface(image,NULL,screen,dest);
SDL_UpdateRects(screen,1,dest);
}
void destroyScreen(SDL_Surface * screen)
{
SDL_FreeSurface(screen);
}
怎么用c语言画函数图像?【c语言自己写图形函数 c语言自己写图形函数怎么做】我画了半个正弦函数,其余的你可以照着画,欢迎讨论,
#include "stdio.h"
#include "conio.h"
#include "math.h"
#include "graphics.h"
void main()
{
int driver,mode,i;
driver=DETECT;
mode=0;
initgraph(driver,mode,"");
setcolor(15);
for(i=0;i360;i++)
line(i,200*sin(i*3.14/360),i+1,200*sin((i+1)*3.14/360));
getch();
restorecrtmode();
}
关于c语言自己写图形函数和c语言自己写图形函数怎么做的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。

推荐阅读