Writing a C++ class for displaying pixel or point on the screen.

A pixel (short for picture element, using the common abbreviation "pix" for "picture") is one of the many tiny dots that make up the representation of a picture in a computer's memory. Each such information element is not really a dot, nor a square, but an abstract sample. With care, pixels in an image can be reproduced at any size without the appearance of visible dots or squares; but in many contexts, they are reproduced as dots or squares and can be visibly distinct when not fine enough. The intensity of each pixel is variable; in color systems, each pixel has typically three or four dimensions of variability such as red, green and blue, or cyan, magenta, yellow and black. Fig. Pixel Resolution





Another popular convention is to cite resolution as the total number of pixels in the image, typically given as number of mega pixels, which can be calculated by multiplying pixel columns by pixel rows and dividing by one million. Other conventions include describing pixels per length unit or pixels per area unit, such as pixels per inch or per square inch. None of these pixel resolutions are true resolutions, but they are widely referred to as such; they serve as upper bounds on image resolution. Below is an illustration of how the same image might appear at different pixel resolutions, if the pixels were poorly rendered as sharp squares (normally, a smooth image reconstruction from pixels would be preferred, but for illustration of pixels, the sharp squares make the point better).

1) Loading computer graphics:-
When we start with the turbo c editor. We first includes the graphics library to convert the text editor into graphics editor. To include the graphics library the steps are
i) Select the option menu from the menu bar
ii) Select linker option
iii) Select libraries from linker option
iv) Select graphics library from the libraries window
v) Click on Ok.

2) Initialized the graphics Mode:-
Before writing the computer graphics program, first we initialize the graphics driver and graphics mode, for that purpose we use detectgraph() function and initgraph() function.
Detectgraph():- determines the graphics driver and chooses mode by checking hardware.
Syntax:-detectgraph(&gdriver, &gmode);

Initgraph():- It initializes graphics system. To start the graphic system , you must first callinitgraph(), initgraph initializes the graphic system by loading a graphics driver from disk, then putting into the graphics mode.
Syntax:-initgraph(&gdriver,&gmode,”C:\\tc\\bgi”);

“bgi” is a file that stores the graphics driver and for each bgi driver there are different graphics mode. In short, it provides graphics interface.

Inbuilt functions :-
Following are inbuilt functions of graphics library:-
1). Line ():- Line () is used to draw a line.
Line(x1,y1,x2,y2);

2). Circle(): is used to draw the circle.
Syntax: circle(x1,y1,radius);

3). drawpoly() :- draws the outline of a polygon, draws a polygon using the current line style and color.
Drawpoly(numpoints,*polypoints);
Numpoints:- specifies number of points
*polypoints :- points to a sequence of (numpoints*2) integers.




4). Outtext: -Display a string in the viewportVoid far outtext(char far textstring);
Example: - outtext(display text in graphics);

5). Putpixel: - plots a pixel at specified point.
Syntax: void far putpixel (int x, inty,intpixelcolor);
Example:putpixel(100,100,15);

6). Closegraph: shuts down the graphics
modeSyntax: -void far close graph( void ); Example: - closegraph( );

Conclusion:- Hence, we have studied displaying pixel or point on the screen.
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: