CS 686: Programming SuperVGA Graphics Devices Introduction: An exercise in working with graphics file formats.

Slides:



Advertisements
Similar presentations
Pixels and Digital Images Yrd. Doc. Dr. Ahmet Sayar Kocaeli Universitesi Bilgisayar Muhendisligi Ileri Bilgisayar Grafikleri.
Advertisements

Introduction to Computers Part II
Lecture 2 Concepts, Terms and Definitions. Display Devices They are divided into a lot of small squares called pixels (“PICture ELements”). Each pixel.
Using VMX within Linux We explore the feasibility of executing ROM-BIOS code within the Linux x86_64 kernel.
VGA Text Mode An introduction to font selection and to reprogramming of the Character Generator ram.
Operating-System Structures
Programming Super-VGA Graphics Devices Introduction to VESA graphics modes and to organization of the linear frame-buffer memory.
The Linux PCI Interface An introduction to the PCI configuration space registers.
SiS 315 Graphics Engine Introduction to some capabilities of graphics accelerator hardware.
The CRT Controller How to modify CRTC registers to achieve a non-standard horizontal and vertical screen resolution.
Bits are Not just for Numbers Computers store characters as bits or binary digits. Characters from the English-language keyboard are represented in ASCII.
Access to video memory We create a Linux device-driver that gives applications access to our graphics frame-buffer.
Direct I/O Programming An introduction to the Pentium’s mechanism for programming peripheral hardware components.
Wire-frame Modeling An application of Bresenham’s line-drawing algorithm.
Graphics Bitmaps Drawing characters glyphs and multicolor patterns.
The ‘ioctl’ driver-function On implementing a way to query and modify our UART’s baudrate via the ‘device-file’ abstraction.
CS 686: Programming SuperVGA Graphics Devices Introduction: An exercise in working with graphics file formats.
A device-driver for Video Memory Introduction to basic principles of the PC’s graphics display.
VGA Color Registers How we can reprogram the Digital-to-Analog Converter’s 256 color-table registers.
VGA System Services How to use Linux’s ‘vm86()’ system-call to access the video ROM-BIOS functions.
SiS 315 An introductory exploration of features of the SVGA graphics processor used in our classroom’s workstations.
1 King ABDUL AZIZ University Faculty Of Computing and Information Technology CS 454 Computer graphicsIntroduction Dr. Eng. Farag Elnagahy
Image Representation.
Ch 1 Intro to Graphics page 1CS 367 First Day Agenda Best course you have ever had (survey) Info Cards Name, , Nickname C / C++ experience, EOS experience.
Introduction to Computer Graphics
Monitors and Sound Systems section 3A This lesson includes the following sections: · Monitors · PC Projectors · Sound Systems.
Digital Images. Scanned or digitally captured image Image created on computer using graphics software.
 Scanned or digitally captured image  Image created on computer using graphics software.
An Introduction to Scanning and Storing Photographs and Graphics Bryn Jones Aug 2002
1 Internet Graphics. 2 Representing Images  Raster Image: Images consist of “dots” of color, not lines  Pixel: Picture element-tiny rectangle  Resolution:
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.
Peripherals and Storage Looking at: Scanners Printers Why do we need storage devices anyway? What are magnetic disks? How do magnetic disks physically.
IE433 CAD/CAM Computer Aided Design and Computer Aided Manufacturing Part-2 CAD Systems Industrial Engineering Department King Saud University.
Digital Images The digital representation of visual information.
1 Bitmap Graphics It is represented by a dot pattern in which each dot is called a pixel. Each pixel can be in any one of the colors available and the.
Unit 30 P1 – Hardware & Software Required For Use In Digital Graphics
Fundamentals of Photoshop
COMP Bitmapped and Vector Graphics Pages Using Qwizdom.
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.
Raster-scan system In addition to the central processing unit a special purpose processor called the video controller or display controller is used to.
ECE291 Computer Engineering II Lecture 9 Josh Potts University of Illinois at Urbana- Champaign.
Video Monitor Uses raster scanning to display images –Beam of electrons illuminates phosphorus dots on the screen called pixels. Starting at the top of.
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 14 Introduction to Computer Graphics.
1 Operating System Overview. 2 Today’s Objectives Explain the main purpose of operating systems and describe milestones of OS evolution Explain fundamental.
Chapter 2: Operating-System Structures. 2.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 2: Operating-System Structures Operating.
Laface Operating System Design Booting a PC to run a kernel from Low memory VGA display.
Digital Darkroom I Theresa L. Ford. Objectives Basic Digital Image Terminology Screen Display of Pictures –Why are pictures too big for the screen? –Why.
Using HiColor graphics
GRAPHICS. Topic Outline What is graphic. Resolution. Types of graphics. Using graphic in multimedia applications.
Department of Electrical Engineering Electronics Computers Communications Technion Israel Institute of Technology High Speed Digital Systems Lab. High.
CS- 375 Graphics and Human Computer Interaction Lecture 1: 12/4/1435 Fundamental Techniques in Graphics Lecturer: Kawther Abas.
ECE291 Lecture 12 Mode 13h Graphics. ECE 291 Lecture 12Page 2 of 27 Lecture outline Color theory Video Hardware Mode 13h Graphics File Formats.
ECE291 Computer Engineering II Lecture 15 Josh Potts University of Illinois at Urbana- Champaign.
Graphics An image is made up of tiny dots called pixels (“picture elements”) The resolution determines the.
 Scanned or digitally captured image  Image created on computer using graphics software.
Lecture 7: Intro to Computer Graphics. Remember…… DIGITAL - Digital means discrete. DIGITAL - Digital means discrete. Digital representation is comprised.
CS1372: HELPING TO PUT THE COMPUTING IN ECE CS1372 Some Basics.
Digression on r/w ‘/proc’ files An application of kernel module programming to Super VGA graphics device control.
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.
Image Editing Vocabulary Words Pioneer Library System Norman Public Library Nancy Rimassa, Trainer Thanks to Wikipedia ( help.
Graphics and Image Data Representations 1. Q1 How images are represented in a computer system? 2.
Lecture 11 Text mode video
By tom squire.  Graphic cards are made of millions of dots called pixels. Graphic cards take data from the CPU and turn it into a picture. At most common.
Computer Graphics Lecture 03 Graphics Systems Cont… Taqdees A. Siddiqi
8th Lecture – Intro to Bitmap or Raster Images
Images Data Representation.
Microprocessor and Assembly Language
An Introduction to Scanning and Storing Photographs and Graphics
Representing Images 2.6 – Data Representation.
Multimedia System Image
Presentation transcript:

CS 686: Programming SuperVGA Graphics Devices Introduction: An exercise in working with graphics file formats

Raster Display Technology The graphics screen is a two-dimensional array of picture elements (‘pixels’) Each pixel’s color is an individually programmable mix of red, green, and blue These pixels are redrawn sequentially, left-to-right, by rows from top to bottom

Special “dual-ported” memory VRAM RAM CPU CRT 32-MB of VRAM 1024-MB of RAM

Graphics programs What a graphics program must do is put appropriate bit-patterns into the correct locations in the VRAM, so that the CRT will show an array of colored dots which in some way is meaningful to the human eye So the programmer must understand what the CRT will do with the contents of VRAM

How much VRAM is needed? This depends on (1) the total number of pixels, and on (2) the number of bits-per-pixel The total number of pixels is determined by the screen’s width and height (measured in pixels) Example: when our “screen-resolution” is set to 1280-by-960, we are seeing 1,228,800 pixels The number of bits-per-pixel (“color depth”) is a programmable parameter (varies from 1 to 32) Some types of applications also need to use extra VRAM (for multiple displays, or for “special effects” like computer game animations)

How ‘truecolor’ works R B G alpharedgreenblue pixel longword The intensity of each color-component within a pixel is an 8-bit value

Intel uses “little-endian” order BGRBGRBGR VRAM Video Screen

Some operating system issues Linux is a “protected-mode” operating system I/O devices normally are not directly accessible On Pentiums: Linux uses “virtual memory” Privileged software must “map” the VRAM A device-driver module is needed: ‘vram.c’ We can compile it using: $ make vram.o Device-node: # mknod /dev/vram c 99 0 Make it ‘writable’: #chmod a+w /dev/vram

VGA ROM-BIOS Our graphics hardware manufacturer has supplied accompanying code (‘firmware’) that ‘programs’ VGA device components to operate in various ‘standard’ modes But these firmware routines were not written with Linux in mind: they’re for interfacing with ‘real-mode’ MS-DOS Some special software is needed (‘lrmi’)

Class demo: ‘pcxphoto.cpp’ First: several system-setup requirements Some steps need ‘root’ privileges (‘sudo’) Obtain demo sources from class website Install the ‘mode3’ program (from svgalib) Compile character device-driver: ‘vram.c’ Create ‘dev/vram’ device-node (read/write) Start Linux in ‘text mode’ (need to reboot)

Typical ‘program-structure’ Usual steps within a graphics application: – Initialize video system hardware – Display some graphical imagery – Wait for a termination condition – Restore original hardware state

Hardware Initialization The VGA system has over 300 registers They must be individually reprogrammed Eventually we will study those registers For now, we just ‘reuse’ vendor routines Such routines are built into VGA firmware However, invoking them isn’t trivial (since they weren’t designed for Linux systems)

Obtaining our image-data Eventually we want to ‘compute’ images For now, we ‘reuse’ pre-computed data Data was generated using an HP scanner It’s stored in a standard graphic file-format Lots of different graphic file-formats exist Some are ‘proprietary’ (details are secret) Other formats are public (can search web)

Microsoft’s ‘.pcx’ file-format FILE HEADER (128 bytes) IMAGE DATA (compressed) COLOR PALETTE (768 bytes)

Run-Length Encoding (RLE) A simple technique for ‘data-compression’ Well-suited for compressing images, when adjacent pixels often have the same colors Without compression, a computer graphics image-file (for SuperVGA) would be BIG! Exact size depends on screen-resolution Also depends on the display’s color-depth (Those parameters are programmable)

How RLE-compression works If multiple consecutive bytes are identical: example:0x29 0x29 0x29 0x29 0x29 (This is called a ‘run’ of five identical bytes) We “compress” five bytes into two bytes: the example compressed: 0xC5 0x29 Byte-pairs are used to describe ‘runs’: Initial byte encodes a ‘repetition-count’ (The following byte is the actual data)

Decompression Algorithm inti = 0; do { read( fd, &dat, 1 ); if ( dat < 0xC0 ) reps = 1; else { reps = (dat & 0x3F); read( fd, &dat, 1 ); } do { image[ i++ ] = dat; } while ( --reps ); } while ( i < npixels );

Standard I/O Library We call standard functions from the C/C++ runtime library to perform i/o operations on a device-file (e.g., vram): open(), read(), write(), lseek(), mmap() The most useful operation is ‘mmap()’ It lets us ‘map’ a portion of VRAM into the address-space of our graphics application So we can ‘draw’ directly onto the screen!

Where will VRAM go? We decided to use graphics mode 0x013A It’s a ‘truecolor’ mode (32bpp) It uses a screen-resolution of 640x480 Size of VRAM needed: 640*480*4 bytes So we ‘map’ 2-MB of VRAM to user-space We can map it to this address-range: 0xB xB

Virtual Memory Layout Linux kernel stack VRAM code and data runtime library 0x x xB xC user space (3GB) kernel space (1GB)

Color-to-Grayscale Sometimes a color image needs to be converted into a ‘grayscale’ format Example: print a newspaper photograph (the printing press only uses ‘black’ ink) How can we ‘transform’ color photos into black-and-white format (shades of gray)? ‘gray’ colors use a mix of red+green+blue, these components have EQUAL intensity

Color-conversion Algorithm struct { unsigned char r, g, b; } color; int avg = ( 30*r + 49*g + 11*b )/100; color.r = avg; color.g = avg; color.b = avg; longpixel = 0; pixel |= ( avg << 16 );// r-component pixel |= ( avg << 8 );// g-component pixel |= ( avg << 0);// b-component vram[ address ] = pixel; // write to screen

In-class exercise Revise the ‘pcxphoto.cpp’ program so that it will display (1) the ‘color-table’, and then (2) the scanned photograph, as ‘grayscale’ images (i.e., different intensities of gray)