Computer Graphics Bitmaps & Sprites CO2409 Computer Graphics Week 3.

Slides:



Advertisements
Similar presentations
Md. Monjur –ul-Hasan Department of Computer Science & Engineering Chittagong University of Engineering & Technology Chittagong 4349
Advertisements

L.Ghadah R. Hadba CT1514-L1.  Computer Graphics :refers to processing of creating a new image from Geometry, Lighting parameters, Materials and Textures.Using.
Image Data Representations and Standards
Raster graphics. Colour depth 01 1 bit pr pixel = 2 combinations (2 1 ): 2 bits pr pixel = 4 combinations (2 2 ): bits pr pixel = 16 combinations(2.
3.1. G RAPHICS I The use of images within games. Reflections and advice on the games proposed in the Week 2 Hand-in.
Graphics in the web Digital Media: Communication and Design
Introduction to Computer Graphics
How Images are Represented Bitmap images (Dots used to draw the image) Monochrome images 8 bit grey scale images 24 bit colour Colour lookup tables Vector.
Manipulating Images Image A visual representation of something that is seen in real life. It can be two-dimensional or three-dimensional A visual representation.
Part A Multimedia Production Rico Yu. Part A Multimedia Production Ch.1 Text Ch.2 Graphics Ch.3 Sound Ch.4 Animations Ch.5 Video.
Data starts with width and height of image Then an array of pixel values (colors) The number of elements in this array is width times height Colors can.
Zinnia Bell. RAWimages are image files that have not yet processed, they contain minimally processed data from the image sensor of either a image scanner,
1 Creating Web Graphics Outline 2.1 Graphics Types 2.2 Vector Graphics 2.3Bitmapped Graphics 2.4Graphics for the Web 2.5 GIF (Graphics Interchange Format)
Prepared by George Holt Digital Photography BITMAP GRAPHIC ESSENTIALS.
CS 1308 Computer Literacy and the Internet. Creating Digital Pictures  A traditional photograph is an analog representation of an image.  Digitizing.
Faculty of Sciences and Social Sciences HOPE Website Development Graphics Stewart Blakeway FML 213
File Formats COM 366 Web Design & Layout. Native file format –Format native to software program –.psd > PhotoShop default Preserves layers –Use “Save.
COMP Bitmapped and Vector Graphics Pages Using Qwizdom.
Module Code: CU0001NI Technical Information on Digital Images Week -2.
Lecture 4 - Introduction to Computer Graphics
Lab #5-6 Follow-Up: More Python; Images Images ● A signal (e.g. sound, temperature infrared sensor reading) is a single (one- dimensional) quantity that.
Tools for Raster Displays CVGLab Goals of the Chapter To describe pixmaps and useful operations on them. To develop tools for copying, scaling, and rotating.
Image Storage Bitmapped Graphics – in which an image is represented as a collection of dots Vector Graphics – in which an image is represented as a set.
Computer Graphics Texture Mapping
Bit-Mapped Graphic Data: Input (Capture) Hardware Multimedia – Section 2.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 5 Working with Images Starting Out with Games & Graphics in.
Common file formats  Lesson Objective: Understanding common file formats and their differences.  Learning Outcome:  Describe the type of files which.
3D Game Programming All in One By Kenneth C. Finney.
Digital Cameras And Digital Information. How a Camera works Light passes through the lens Shutter opens for an instant Film is exposed to light Film is.
Lecture 4 Pixels, Images and Image Files 1. In this Lecture, you will learn the following concepts: Image files (in particular, the BMP file format) How.
Pixels, Images and Image Files 1 By Dr. HANY ELSALAMONY.
Information Processes and Technology Multimedia: Graphics.
Computer Graphics The Rendering Pipeline - Review CO2409 Computer Graphics Week 15.
Digital Multimedia, 2nd edition Nigel Chapman & Jenny Chapman Chapter 3 This presentation © 2004, MacAvon Media Productions Introduction to Computer Graphics.
Advanced Computer Graphics Advanced Shaders CO2409 Computer Graphics Week 16.
CS- 375 Graphics and Human Computer Interaction Lecture 1: 12/4/1435 Fundamental Techniques in Graphics Lecturer: Kawther Abas.
GRAPHIC DESIGN – PHOTOSHOP AND FLASH Instructor: Qumber Hussain Start: 24 Aug 2009 End: 28 Sept 2009 Days/Time: Mon & Wed 1400 – AUGUST 2009 –
Graphics workshop Library and Information Services University of St Andrews.
2D Graphics Theory & Principles. Single Point Smallest addressable area on screen or digital image.
Computer Graphics Blending CO2409 Computer Graphics Week 14.
Images. Digital Images Rectangular arrays of pixel data Pixel - picture element, smallest addressable part of the frame buffer. Color depth - the depth.
Raster Graphics 2.01 Investigate graphic image design.
Digital Images are represented by manipulating this…
Image File Formats. What is an Image File Format? Image file formats are standard way of organizing and storing of image files. Image files are composed.
Introduction to Images & Graphics JMA260. Objectives Images introduction Photoshop.
Digital File Formats By Ali Aslam. JPEG JPEG Stands for Joint Photographic Experts Group. JPEG uses a lossy compression routine. Lossy compression means.
Image File Formats By Dr. Rajeev Srivastava 1. Image File Formats Header and Image data. A typical image file format contains two fields namely Dr. Rajeev.
HTTP transaction with Graphics HTML file + two graphics files.
Image File Formats Harrow Computer Club – Wed, 1 Dec 2010 Bob Watson MA CMath MIMA MBCS.
Image Editing Vocabulary Words Pioneer Library System Norman Public Library Nancy Rimassa, Trainer Thanks to Wikipedia ( help.
Scanner Scanner Introduction: Scanner is an input device. It reads the graphical images or line art or text from the source and converts.
Graphics and Image Data Representations 1. Q1 How images are represented in a computer system? 2.
Understanding Images. Pixels pixels Every image is made up of very small squares called pixels, and each pixel represents a color or shade. Pixels within.
DIGITAL MEDIA FOUNDATIONS
Computer Science Higher
Chapter 3 Graphics and Image Data Representations
2.01 Investigate graphic image design.
Raster Images CPSC 1030.
"Digital Media Primer" Yue-Ling Wong, Copyright (c)2013 by Pearson Education, Inc. All rights reserved.
A computer display is made up of small squares, called pixels.
Digital Images.
Image File Size and File Compression
Look at Me Mod 4 Lesson 3 Graphics Module 4- Build a Game.
Introduction to Computer Graphics
Data Representation.
Representing Images 2.6 – Data Representation.
COMS 161 Introduction to Computing
Multimedia System Image
Lecture 4 - Introduction to Computer Graphics
"Digital Media Primer" Yue-Ling Wong, Copyright (c)2013 by Pearson Education, Inc. All rights reserved.
Presentation transcript:

Computer Graphics Bitmaps & Sprites CO2409 Computer Graphics Week 3

Today’s Lecture 1.Bitmaps & File Formats 2.Sprites 3.Blending Methods 4.Transparency / Alpha Data 5.Alpha Blending

Limitations of 2D Geometry Rendering 2D geometry is simplistic, but can be effective for: –Line drawings –Vector-based work –Simple graphic design But to render anything complex would need excessive detail Use another method…

Bitmaps A bitmap is rectangle of pixels stored off-screen Bitmaps can come from several sources: –Hand-drawn (e.g. using Photoshop, Maya or even last week’s PixelPlotter) –A single capture from a camera, scanner or video –Other 2D data, e.g. satellite data –An algorithm for generating pixels (procedural textures)

Displaying Bitmaps The pixels of a bitmap are usually copied into a rectangular region of a viewport –Can be the entire viewport (a background) If region copied to is same size as the bitmap this is a simple pixel-by-pixel copy Otherwise the bitmap will must be scaled –Will see details this operation when we look at textures We can also copy a bitmap to a rotated or distorted region – a more complex process These operations can be done in hardware

Bitmap File Formats We usually need to store bitmaps for reuse There are many possible data formats, each with different benefits and drawbacks: –BMP (Windows bitmap) –JPEG (.jpg) (Joint Photographic Experts Group) –GIF (Graphics Interchange Format) –PNG (Portable Network Graphics) –TGA (Truevision Targa) –DDS (DirectDraw Surface – bitmap for DirectX) –And many more… One of the example bitmaps earlier would not typically be stored in a file, which one?

General Bitmap Format Most bitmap formats contain additional data apart from the pixels: –Width and Height –Colour space/range (e.g. RGB 0-255) Other data can be stored: –E.g. printing size, title, comments, pixel format etc. Pixel data may be stored in a range of formats: –Raw pixel data (R, G & B values): TGA, BMP –Compressed: GIF (zip), TGA,BMP (RLE) –Lossy Compressed: JPEG

Bitmap Compression Pixel data can be compressed in most formats Some compression methods only store an approximation of the pixels for better compression –Called lossy compression –The idea is that the eye does not notice the inaccuracies –Jpeg’s are a notable example –Repeatedly saving in a lossy format will degrade quality Lossy compression schemes can reduce data size 100x or more JPEG (Lossy) PNG format (Non-Lossy Compressed )

Sprites A sprite is a name given to a particular use of bitmaps Sprites are used as distinct elements in a larger scene, e.g: –A character in a 2D game –A mouse cursor –A letter in a font Sprites may be layered (perhaps with a background image) to create a complex picture. –Example is from Metal Slug 3

Pixel Data for Sprites Sprites usually represent non-rectangular objects Cannot just copy data from bitmap to viewport as described above –The bitmap rectangle will obscure any detail below Need to overlay the sprite with the background in some way: – Using cutout or blending methods

Pixel Blending Pixel blending are methods to combine the RGB colours in the bitmap with those already on the viewport We use a blending equation to precisely specify the method used –Different blending equations give different effects Blending creates various forms of transparency: –Semi-transparent objects: glass, plastic, membranes –Effects that brighten the scene: fire, glow, lens flare –Or obscure (darken) the scene: smoke, dust, shadows –Plus other effects: e.g. user interface elements

Multiplicative Blending The multiplicative blending equation is: Final.Red = Bitmap.Red * Viewport.Red Similar for green and blue, RGB range is [0-1] –Combine bitmap pixel colour with existing viewport pixel colour –Final colour the new colour written to the viewport –Do seperately for R, G & B –If RGB in range 0-255, result would need to be divided by 255 This is a darkening effect, suitable for representation of glass, shadows, smoke etc –If source pixel is white, destination colour stays same –As source pixel tends to black, destination is darkened

Multiplicative Blending Example Test Pattern Multiplicative Smoke

Additive Blending and Others The additive blending equation is: Final.Red = Bitmap.Red + Viewport.Red Similar for green and blue, RGB range is [0-1] or [0-255] This is a lightening effect, mainly used for the representation of lights –Bitmap black = no effect, brightens as bitmap becomes whiter Many other blending equations are possible, e.g.: Final.Red = 2 * (Bitmap.Red * Viewport.Red) –Darkens & lightens depending on bitmap colour Final.Red = (Bitmap.Red + Viewport.Red) / 2 –Average of bitmap and viewport colour

Additive Blending Example Test Pattern Additive Flare

Transparency / Alpha Data The previous examples used RGB data only For each pixel can store an extra value to identify if the pixel is transparent or not Can be a single bit: –1: visible, 0: transparent –Or sometimes the other way round This is called Alpha data, or the alpha channel Using this data we can draw a cutout sprite: –Only copy the pixels that have a non-zero alpha value

Blending using Alpha We can specify a range of alpha values for a pixel (not just 0 or 1) –Allowing us to set a level of transparency for the pixel –Allows semi-transparent pixels Alpha values are usually in the range or and are called A –Treated just like R, G and B –Packed together with RGB to make RGBA colours Can use this alpha channel in blending methods –Usually only the bitmap alpha value is used –Generally avoid use of viewport alpha

Alpha Blending The usual alpha blending equation is: Final.Red = Bitmap.Red * Bitmap.Alpha + Destination.Red * (1 – Bitmap.Alpha) Similar for green and blue, RGBA range is [0-1] [N.B. This formula is a linear interpolation between bitmap and viewport colour – we will see this formula again] Notice how only the bitmap alpha is used Alpha blending allows for variable transparency based on the alpha value –Low alpha = very transparent, high alpha = very opaque –It can be used for precise transparency effects

Alpha Blending Example Test Pattern RGB Channel Alpha Channel Alpha allows variable transparency

Packed Pixel Data with Alpha So we have now identified four channels of data for a typical pixel: –Red, Green, Blue and Alpha –Such data is often called ARGB or RGBA data If each channel is a byte (0-255) then a single pixel is a double-word (4 bytes) –Efficient for hardware, called ARGB 8888 format There are other packing schemes: –1 bit for A, 5 bits for R,G & B: ARGB 1555 format –4 bits each for A, R, G & B: ARGB 4444 format –5 bits for R & B, 6 for G, 0 for A: RGB 565 –32 bit floats for each: ARGB 32F32F32F32F –These will be relevant for GPU-based graphics later…