鱼C论坛

 找回密码
 立即注册
查看: 3925|回复: 4

putpixel

[复制链接]
发表于 2014-8-12 08:50:44 | 显示全部楼层 |阅读模式
20鱼币
本帖最后由 2764315761 于 2014-8-12 22:27 编辑

putpixel怎么用啊?写一个简单的程序就行,让我知道这个函数怎么写
难道tc上才能用这个函数吗?

最佳答案

查看完整内容

函数名: putpixel 功 能: 在指定位置画一像素 用 法: void far putpixel (int x, int y, int pixelcolor); 程序例: #include #include #include #include #include #define PIXEL_COUNT 1000 #define DELAY_TIME 100 /* in milliseconds */ int main(void) { /* request autodetection */ int gdriver = DETECT, gmode, errorcode; int i, x, y, color, maxx, maxy, maxcolor, seed; /* initialize graphics ...
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2014-8-12 08:50:45 | 显示全部楼层
函数名: putpixel
功 能: 在指定位置画一像素
用 法: void far putpixel (int x, int y, int pixelcolor);
程序例:
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#define PIXEL_COUNT 1000
#define DELAY_TIME 100 /* in milliseconds */
int main(void)
{
/* request autodetection */
int gdriver = DETECT, gmode, errorcode;
int i, x, y, color, maxx, maxy, maxcolor, seed;
/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "");
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
}
maxx = getmaxx() + 1;
maxy = 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 = random(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;
}
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2014-8-12 12:36:36 | 显示全部楼层
745627933 发表于 2014-8-12 12:28
函数名: putpixel
功 能: 在指定位置画一像素
用 法: void far putpixel (int x, int y, int pixelcolor) ...

画一个点就需要写这么长的程序?{:7_166:}
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2014-8-12 15:17:12 | 显示全部楼层
745627933 发表于 2014-8-12 12:28
函数名: putpixel
功 能: 在指定位置画一像素
用 法: void far putpixel (int x, int y, int pixelcolor) ...

这句程序的输出结果是什么
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2014-8-13 12:18:37 | 显示全部楼层
功 能: 在指定位置画一像素
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-6-12 21:57

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表