Presentation is loading. Please wait.

Presentation is loading. Please wait.

6th Lecture – Rectangles and Regions, and intro to Bitmap Images

Similar presentations


Presentation on theme: "6th Lecture – Rectangles and Regions, and intro to Bitmap Images"— Presentation transcript:

1 6th Lecture – Rectangles and Regions, and intro to Bitmap Images
CPT 450 Computer Graphics 6th Lecture – Rectangles and Regions, and intro to Bitmap Images

2 Rectangles The Rectangle structure stores the top left starting point (x, y) and the width and height. The Rectangle can be constructed with new Rectangle (point, size) or new Rectangle (x, y, w, h) Notes: A (2D) point object contains an x and y coordinate A size object contains a width and height. There are integer and a floating point (single precision) versions of these objects. The floating point versions end in the letter F.

3 More on Rectangles It has methods to return the left, top, right, and bottom coordinates. Where Left = x Top = y Right = x + w Bottom = y + h Also has round, truncate, inflate, ceiling, intersect and union methods. The “contains” method can be used to test if the user clicks inside a rectangle, i.e. left < point.x < right AND top < point.y < bottom

4 Region Class A region describes the interior of a closed graphics shape or form. A form has 2 regions Client area, the area where the user can draw Non client area, such as the title bar, the scroll bars, etc.. Contructor has overloaded versions which take rectangles, graphicsPath or region data. No properties The graphics object g has a fill method, i.e. g.fillRegion to shade the region

5 Region Methods Many methods. See documentation. For combining regions,
Compliment Exclude Union Intersect Xor Regions can be used for clipping. Author’s sample creates non-rectangular forms. (used by Music/Video players)

6 Graphics Path You can combine many vector drawing methods into a graphics path. Then you can use the path to draw a shape. Example If you draw lots of a particular pattern in your program, then you can create a graphics path and use it to draw each shape (like a subroutine).

7 Intro to Bitmap or Raster Images

8 What is the difference between bitmap and vector graphics?
A bitmap or raster image is a collection of pixels (picture element), each with it’s own independent color. A vector image is made up of vector graphics instructions such as drawLine or drawEllipse. Converting from one type to another From vector to raster – this is called scan conversion From raster to vector – this is called pattern recognition or OCR

9 Where do they come from? Digital Cameras (now in cell phones)
Optical Scanners Video Fax Medical Imaging (X-ray, CAT Scan, MRI) Satellite data Generated by scan converting vector graphics instructions Internet (google)

10 How are bitmap or raster images stored?
Generally, the images are rectangular and can be represented in matrix form (row, column), as a table of colors. In the file, they are store sequentially. Could be either (row, column) or (column, row) In the old days, the pixels on the screen were directly mapped to the video memory, hence the word “map”. Video memory could be addressed directly by the programmer. This was fast and convenient but very dangerous. The image files can contain a header and footer. This can contain the width and height of the image, the color depth, and other info about the image.

11 Some Image File formats
File types File extensions Bitmap bmp Icon Ico Cursor cur Windows meta file wmf GIF gif JPEG jpg or jpeg TIFF tif or tiff

12 Grayscale images Gray scale images only require 1 intensity per pixel (remember R=G=B), instead of 3 for color (excluding transparency) 8 bits/pixel can display 256 shades of gray. 1 bit/pixel can display only two shades, black or white Using dithering, newpapers can create shades of grade, by varying the size of the dots in the picture.

13 Dithering Dithering – used to create the appearance of a new color by combining different sized dots of different colors. See the comics in the Sunday newspaper!

14 The Art of Roy Lichtenstein (an example of dithering)


Download ppt "6th Lecture – Rectangles and Regions, and intro to Bitmap Images"

Similar presentations


Ads by Google