Professional Documents
Culture Documents
Unit 1
Unit 1
• lineto():
– Draws a line from current position to the point (x , y).
• getpixel():
– Returns the color of pixel present at location (x,y)
• getx():
– Returns the x coordinate of the current position
Primitive Operations
• gety():
– Returns the y coordinate of the current position.
• graphdefaults():
– Resets all graphics setting to their defaults.
– It resets the following graphics setting:
• Sets the view port to the entire screen
• Moves the current position to (0,0)
• Sets the default palette color, background color and drawing
color.
• Sets the default fill style and pattern.
• Sets the default text font and justification.
Primitive Operations
• putpixel():
– Plots a pixel at location (x , y) of specified color.
• setbkcolor():
– Changes current background color.
– E.g. setbkcolor(YELLOW)
– Default background color is BLACK.
• setcolor():
– Changes the current drawing color.
– setcolor(4) or setcolor(RED)
• setfillstyle():
– Sets the current fill pattern and fill color.
– Setfillstyle(int style, int color)
– EMPTY_FILL, SOLID_FILL, LINE_FILL, LTSLASH_FILL,
SLASH_FILL, BKSLASH_FILL, INTERLEAVE_FILL
Graphics File Formats
• BMP:
– Also known as bitmap image file / device independent
bitmap (DIB)
– Created by Microsoft and IBM
– Used to store 2D digital images independently of the display
devices.
– BMP files are stored bottom-up, i.e. the first scan line is
bottom line.
– Mostly used in Windows and OS/2.
– Usually named with the file extension of .BMP or .DIB
– Adv:
• Simple and common
• Free of patents
• Many old GUI uses bitmap
Graphics File Formats
• BMP:
– Disadvantage:
• relatively large size due to lack of any compression.
• They are not upward scalable.
• Strictly bound to the architecture of Microsoft and IBM.
Graphics File Formats
• GIF:
– Graphics Interchange Format
– It is a bitmap image format that was introduced by
CompuServe in 1987
– Supports up to 8 bits per pixel for each image.
– GIF is palette based where palette table can hold upto
256 entries.
– Supports animation.
– Compressed using LZW lossless compression technique
– Commonly used for menu buttons or icons, charts or
diagrams, cartoon-like drawings, banners etc.
Graphics File Formats
• GIF:
– Advantages:
• Small in size, can be used easily online.
• Good quality.
• Also supports transparent background, so animation can be
used over a different background.
– Disadvantages:
• Have a max color palette of 256 colors.
• Once the animation has been coded into the GIF file, there is
no way to edit the image.
Graphics File Formats
• GIF:
Graphics File Formats
• JPEG:
– Joint Photographic Experts Group
– Extension for a lossy graphics file.
– Defines how an image is compressed into a stream of
bytes and decompressed back into an image.
– 2 sub formats:
• JPG/Exif (digital cameras and photographic equipments)
• JPG/JFIF (World Wide Web)
– JPG files can be opened by most image editing software
like MS Paint to Adobe Photoshop.
Graphics File Formats
• JPEG:
– Advantages:
• Global format
• Compatible with every printers and photo editing softwares
• Jpeg files are compressed.
• Images can be compressed up to 5% of their original size.
– Disadvantages:
• It’s a lossy compression technique, significant amount of
information is lost.
• Jpeg images are of lower quality than other formats.
• Does not support animation
• Does not support layer
• Files cannot have transparent bachground
• Only uses 8-bits of color data, whereas modern digital cameras can
capture color using 10 or 14-bits of data.
Graphics File Formats
• TIFF:
– It was designed jointly by Aldus and Microsoft with
leading scanner vendors to facilitate incorporating
scanned images into publishing.
– It is widely supported by image-manipulation
applications, publishing and page-layout applications,
scanning, faxing, OCR and other applications.
Operating Modes
• Graphics Mode:
– A way of displaying images on a computer screen or other
graphics devices such that the basic unit is the pixel.
– The more bits per pixel, the more different colors or shades
of gray.
Operating Modes
• Text Mode:
– A way of using computer display such that the basic unit is
the character cell- the space taken up by a single character.
– the only images that can be displayed are those that can be
built from character sized blocks.
phosphor.
• The color depends on how far the electron beam