Лабораторная работа №4
.doc
Министерство Образования РФ
Санкт- Петербургский государственный
электротехнический университет “ЛЭТИ”
ФКТИ
Кафедра ВТ
Отчет по лабораторной работе №4
“Исследование видеосистем ”
По дисциплине “Организация ЭВМ”
Выполнил:
студент группы 3371,
Артемьев Ю.Г
Проверил:
Степашкин Г.И.
Санкт – Петербург
2005
Текст программы( Исследование видеосистем ):
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <dos.h>
void _putpixel( int iX, int iY, int iColor, int iPro = 5)
{
int i, j;
int iMaxX = getmaxx();
int iMaxY = getmaxy();
for( i = -iPro; i < iPro; i++ )
{
for( j = - iPro; j < iPro; j++ )
{
int iRealX = iX + i;
int iRealY = iY + j;
if( (iRealX >= 0) && (iRealY >= 0) && (iRealX < iMaxX)
&& (iRealY < iMaxY) )
{
putpixel( iRealX, iRealY, iColor );
}
}
}
}
int main(void)
{
/* request auto detection */
int gdriver = VGA/*DETECT*/, gmode = VGAHI, errorcode;
int i, iColor1, iColor2, iColor3;
int poly[5];
/* initialize graphics, 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 */
}
printf( "Input the color of the first side ");
scanf( "%d", &iColor1 );
printf( "Input the color of the second side ");
scanf( "%d", &iColor2 );
printf( "Input the color of the third side ");
scanf( "%d", &iColor3 );
int iXCenter;
int iYCenter;
int iLen;
printf( "Input the center of figer( OX(0 - 640) ) ");
scanf( "%d" ,&iXCenter);
printf( "Input the center of figer( OY(0 - 480) ) ");
scanf( "%d" ,&iYCenter);
printf( "Input the side of figer ");
scanf( "%d", &iLen );
poly[0] = iXCenter - iLen;
poly[1] = iYCenter + iLen;
poly[2] = iXCenter + iLen;
poly[3] = iYCenter + iLen;
poly[4] = iXCenter + iLen;
poly[5] = iYCenter - iLen;
poly[6] = iXCenter - iLen;
poly[7] = iYCenter - iLen;
poly[8] = poly[0];
poly[9] = poly[1];
for (i=EMPTY_FILL; i<SOLID_FILL; i++)
{
setfillstyle(7, iColor1);
fillpoly(5, poly);
delay(500);
}
poly[0] = iXCenter + iLen;
poly[1] = iYCenter + iLen;
poly[2] = iXCenter + iLen;
poly[3] = iYCenter - iLen;
poly[4] = iXCenter + 2*iLen;
poly[5] = iYCenter - 2*iLen;
poly[6] = iXCenter + 2*iLen;
poly[7] = iYCenter;
poly[8] = poly[0];
poly[9] = poly[1];
for (i=EMPTY_FILL; i<SOLID_FILL; i++)
{
setfillstyle( 8, iColor2 );
fillpoly(5, poly);
delay(500);
}
poly[0] = iXCenter - iLen;
poly[1] = iYCenter - iLen;
poly[2] = iXCenter + iLen;
poly[3] = iYCenter - iLen;
poly[4] = iXCenter + 2*iLen;
poly[5] = iYCenter - 2*iLen;
poly[6] = iXCenter;
poly[7] = iYCenter - 2*iLen;
poly[8] = poly[0];
poly[9] = poly[1];
for (i=EMPTY_FILL; i<SOLID_FILL; i++)
{
setfillstyle(9, iColor3);
fillpoly(5, poly);
delay(500);
}
int iY = 0, iX = 0;
long int iMaxX = getmaxx();
long int iMaxY = getmaxy();
iX = iMaxX/2;
for( iY = iMaxY; iY > (iMaxY/2 - 90); iY-- )
{
_putpixel( iX, iY, random(3)+2 );
delay(10);
_putpixel( iX, iY, 0 );
}
for( i = 1; i < 20; i++ )
{
_putpixel( iX + 2*i + i*i, iY + 3*i*i, random(3)+2);
_putpixel( iX + 3*i + i*i, iY + 2*i*i, random(3)+2);
_putpixel( iX + 4*i + i*i, iY + 4*i*i, random(3)+2);
_putpixel( iX - 2*i - i*i, iY + 3*i*i, random(3)+2);
_putpixel( iX - 3*i - i*i, iY + 2*i*i, random(3)+2);
_putpixel( iX - 4*i - i*i, iY + 4*i*i, random(3)+2);
_putpixel( iX - i - i*i, iY + i*i, random(3)+2);
_putpixel( iX + i + i*i, iY + i*i, random(3)+2);
delay(200);
_putpixel( iX + 2*i + i*i, iY + 3*i*i, 0);
_putpixel( iX + 3*i + i*i, iY + 2*i*i, 0);
_putpixel( iX + 4*i + i*i, iY + 4*i*i, 0);
_putpixel( iX - 2*i - i*i, iY + 3*i*i, 0);
_putpixel( iX - 3*i - i*i, iY + 2*i*i, 0);
_putpixel( iX - 4*i - i*i, iY + 4*i*i, 0);
_putpixel( iX - i - i*i, iY + i*i, 0);
_putpixel( iX + i + i*i, iY + i*i, 0);
}
getch();
closegraph();
return 0;
}