putpixel

百科

putpixel:在指定位置画一像素。void f来自ar putpixel (int x, int y, int pixelcolo扩举跑取则环验r);

其中(x,y)是坐标,pixelcolor是像素的颜

C语言函数

  • 外文名称 putpixel
  • 功能 在指定位置画一像素
  • 程序例 #include <graphics.h>
  • 用法  void far putpixel

  函数名: putpixel

  功 使万势边写德能: 在指定位置画一像

  用 法: void far putpixel (int x, int y, int pixelcolor);

  程序例:

  #include <graphics.h>

  #inclu罪待论续急搞克de <stdlib.h>

  #include <st来自dio.h>

  #include <conio.h>

  #includ360百科e <dos.h>

  #define PIXEL_COUNT 1000

  #defin一棉殖备属秋胡e DELAY_TIME 伯甲浓及晚胜么图妈100 /* in milliseconds */

  int main(void)

  {

  /* request autodetection */

  int gdriver = DETECT, gmode, errorcode;

  int i, x, y, color, maxx, maxy, maxcolor, seed;

  /* initiali陆损架设坐ze graphics and local variables */

  initgraph(&gdriver, &gmode, "");

  /* read result of initialization */

  errorcode = graphresult();

  i适评磁非背银种差掉冲f (errorcode 谈氧始封试供皇!= grOk) /* an err跟讲乐周岁所or occurred */

  {

  printf("Graphics error: %s\n", grapherrormsg(e层样帝流rrorcode));

 鱼胞 printf("Pr属溶才父换接ess any key to halt:");

  getch();

  exit(1); /* terminate with an error code */

  }

  maxx = getmaxx() + 1;

  ma断时穿离大保穿海自似图xy = getmaxy(帝烟育就住与础毫国准容) + 1;

  maxcolor = getmaxcolor() + 1;

  while (!kbhit())

  {

  /* seed the random number generator */

  seed = random(32767);

  srand(seed);

  for (i=0; i<PIXEL_COUNT; i++)

  {

  x = ra区阿ndom(maxx);

  y = random(maxy);

  color 只未钟= random(介益办究某maxcolor);

  putpixel(x, y, color);

  }

  delay(DELAY_TIME);

  srand(seed);

  for (i=0; i<PIXEL_COUNT富取门; i++)

  {

  x = random(maxx);

  y = random(maxy);

  color = random(maxcolor);

  if (color == getpixel(x, y))

  putpixel(x, y, 0);

  }

  }

  /* clean up */

  getch();

  closegraph();

  return 0;

  }

  需要注意的是,如果没有专门添加头文件和库文件,该函数并不能够在vc中使用。

标签:
声明:此文信息来源于网络,登载此文只为提供信息参考,并不用于任何商业目的。如有侵权,请及时联系我们:yongganaa@126.com

评论留言

我要留言

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

声明:此文信息来源于网络,登载此文只为提供信息参考,并不用于任何商业目的。如有侵权,请及时联系我们:yongganaa@126.com