Color How X handles color. Widget use of color n Widgets that use color have u XmNforeground u XmNbackground u XmNborderColor (since default border width.

Slides:



Advertisements
Similar presentations
Introduction to Web Design Lecture number:. Todays Aim: Introduction to Web-designing and how its done. Modelling websites in HTML.
Advertisements

Presented by: Stacy C. Lovell. How do we perceive color? Our eyes contain only 3 types of photosentitive cells tuned to three frequencies Red, Green,
Creative Computing. \\ aims By the end of the session you will be able to: 1.Explain the difference between various image file formats 2.Load in and display.
CS 497C – Introduction to UNIX Lecture 37: - X Windows Chin-Chih Chang
Digital Color 24-bit Color Indexed Color Image file compression
Inpainting Assigment – Tips and Hints Outline how to design a good test plan selection of dimensions to test along selection of values for each dimension.
Measurement Many CSS properties (values within the declaration) require that you specify a unit of measurement, such as spacing between elements, border.
Incorporating Color Techniques
Getting Started: Ansoft HFSS 8.0
Pixmaps, Bitmaps and Images How X applications can create, draw, or process rasters,
Adobe Photoshop CS Design Professional TECHNIQUES INCORPORATING COLOR.
GUIs and Color Here's a first crack at an 8-puzzle widget:
1 Chapter 20 — Creating Web Projects Microsoft Visual Basic.NET, Introduction to Programming.
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.
Using HTML to Create Tables in Web pages Connie Lindsey November 2005.
Digital Images The digital representation of visual information.
8 Copyright © 2004, Oracle. All rights reserved. Creating LOVs and Editors.
C++ / G4MICE Course Session 3 Introduction to Classes Pointers and References Makefiles Standard Template Library.
© 2000 – All Rights Reserved – Page 1 Web Color. © 2000 – All Rights Reserved – Page 2 Issues with Color Every hardware setup is different –graphics card.
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.
XP New Perspectives on Microsoft Office Access 2003 Tutorial 11 1 Microsoft Office Access 2003 Tutorial 11 – Using and Writing Visual Basic for Applications.
© GCSE Computing Candidates should be able to:  explain the representation of an image as a series of pixels represented in binary  explain the need.
Objective Understand concepts used to create digital graphics. Course Weight : 15% Part Three : Concepts of Digital Graphics.
225 City Avenue, Suite 106 Bala Cynwyd, PA , phone , fax presents… HTML Lists, Tables and Forms v2.0.
Lesson 13 – Color and Typography. 2 Objectives Discuss basic color theory. Understand the color wheel. Understand how color is presented on a computer.
CSS The Definitive Guide Chapter 8.  Allows one to define borders for  paragraphs  headings  divs  anchors  images  and more.
INTRODUCTION TO HTML5 Styling Text. Change the Font Size  You can use the font-size property to change the font size for a document’s text.  Instead.
Colours and Computer Jimmy Lam The Hong Kong Polytechnic University.
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 14 Introduction to Computer Graphics.
Tutorial 121 Creating a New Web Forms Page You will find that creating Web Forms is similar to creating traditional Windows applications in Visual Basic.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
1 Performing Spreadsheet What-If Analysis Applications of Spreadsheets.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 5 Working with Images Starting Out with Games & Graphics in.
Most of the attributes of the body element specify colors for the Web page. Note: The background attribute won’t be useful till we learn about graphics.
Computer Science 112 Fundamentals of Programming II Graphics Programming.
1 Ethics of Computing MONT 113G, Spring 2012 Session 10 HTML Tables Graphics on the Web.
Compositing Assays To The Chosen Bench Height ©2007 Dr. B.C. Paul {Note – The Name MineSight® and the Program described are property of Mintec Inc – Tucson,
به نام خدا تنظیم کننده : فرانه حدادی استاد : مهندس زمانیان تابستان 92.
Agenda Last class: Memory, Digitizing Numbers Today: Digitizing: Text
Chapter 2: Color and Applets Coming up: Introduction to Graphics.
CS- 375 Graphics and Human Computer Interaction Lecture 1: 12/4/1435 Fundamental Techniques in Graphics Lecturer: Kawther Abas.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Memory: Relocation.
Fluency with Information Technology INFO100 and CSE100 Katherine Deibel Katherine Deibel, Fluency in Information Technology1.
Computer Systems Nat 4.5 Computing Science Data Representation Lesson 4: Representing and Storing Graphics EXTENSION.
Copyright © 2015 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 13 GUI Programming.
Why a bitmap (.bmp), not a.jpg? If you cannot save a.bmp, make it an uncompressed.tif. Compression (of this 8-bit 397,000 pixel image): none (397kb memory)medium.
The Cursor The user only thinks it is under his control.
Elements of Design 1.02 Investigate Design Principles and Elements.
Lawrence Snyder University of Washington, Seattle © Lawrence Snyder 2004 Drawing pictures … It’s not art, it’s fun.
June 14, ‘99 COLORS IN MATLAB.
Project 5: Using Pop-Up Windows Essentials for Design JavaScript Level One Michael Brooks.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 9 Pointers and Dynamic Arrays.
PART TWO Electronic Color & RGB values 1. Electronic Color Computer Monitors: Use light in 3 colors to create images on the screen Monitors use RED, GREEN,
Chapter 4 -- Color1 Color Open GL Chapter 4. Chapter 4 -- Color2 n The goal of almost all OpenGL applications is to draw color pictures in a window on.
Copyright © 2014 Pearson Addison-Wesley. All rights reserved. Chapter 9 Pointers and Dynamic Arrays.
1 SIC / CoC / Georgia Tech MAGIC Lab Rossignac Processing  Install Processing  Learn how to edit, run, save, export,
XP New Perspectives on Macromedia Dreamweaver MX 2004 Tutorial 5 1 Adding Shared Site Elements.
1 Berger Jean-Baptiste
Lesson 13 – Color and Typography. 2 Objectives Understand basic color theory. Understand the color wheel. Understand how color is presented on a computer.
HTML Structure II (Form) WEEK 2.2. Contents Table Form.
1© 2009 Autodesk Hardware Shade – Presenting Your Designs Hardware and Software Shading HW Shade Workflow Tessellation Quality Settings Lighting Settings.
Hank Childs, University of Oregon April “29 th”, 2015 CIS 330: _ _ _ _ ______ _ _____ / / / /___ (_) __ ____ _____ ____/ / / ____/ _/_/ ____/__ __ / /
The Box Model in CSS Web Design – Sec 4-8
The Box Model in CSS Web Design – Sec 4-8
Images In Matlab.
The Box Model in CSS Web Design – Sec 4-8
Microsoft Office PowerPoint 2010 INSERTING GRAPHIC OBJECTS
Basic Graphics Drawing Shapes 1.
CS320n –Visual Programming
Hank Childs, University of Oregon
Presentation transcript:

Color How X handles color

Widget use of color n Widgets that use color have u XmNforeground u XmNbackground u XmNborderColor (since default border width is 0 this attribute is not often seen) u XmNhighlightColor (widget has focus) n These resources are found in Primitive or Manager and thus inherited by all children.

n Some widgets have additional color resources u ToggleButtons have XmSelectColor for toggle color, u PushButtons have XmNarmColor which changes background when armed, u ScrollBar has XmNthroughColor for the area behind the slider, u...

n Some resources are specialized and handled automatically u XmNtopShadowColor u XmNbottomShadowColor are used to give a 3d effect and are computed automatically from background to be a shade lighter or a shade darker than the background color. If the background color is dynamically changed these may not change automatically. Use XmChangeColor(widget,background) to recalculate and reset shadows

The Problem with Color n What you see is not what you get somewhere else. n Color varies from platform to platform since the value of a color is relative to a colormap data structure.

Colormaps n X assumes the RGB color model. Each pixel’s color is defined by a percent of each of the colors Red, Green, Blue. u All 3 at 100% is white u All 3 at 0% is black u 50% red, 50% green, 0% blue is yellow n It is not like “paint” which is subtractive.

n Each screen pixel has a storage size (8,16,24) bits. The value of this storage is an index into a table of colors called the colormap. n 8 bits is 256 values, so this would define a colormap with 256 entries indexed n Each entry in the colormap is capable of storing one of 256**3 (~16M) colors but a given colormap selects only 256 different colors.

Pixels in X n The data type Pixel is just an index into the colormap. Clients using colors are requesting and using colorcells in the colormap. n In general don’t deal directly with these values. They are best manipulated through library routines. n Clients can create and use different colormaps if needed

X Color Basics n X Color basics assumes u only a few colors are needed u there is space in the colormap (when the server starts it creates a default colormap which it assigns to the root window and is inherited by all applications. There will be some colorcells available for application windows)

X startup n at least two colors will be in the colormap, black and white (0 and 1) but they may not appear black and white if the percentages are changed. n Window managers generally install a few (12?) more colors. n Motif adds a few more (5?) for TopShadow, BottomShadow,.. n Remaining color cells are for applications.

n All active windows have their own small set of colorcells. n Defining colors: u Try not to pick rgb percentages. F #70DB93 (assumes 8 bit) u Names can be chosen from the file rgb.txt which is usually found somewhere in X directories. Usage of these names increases the probablility that the rgb percentages these names represent will be shared in the colormap. F aquamarine

n If resource files are used rc.XmLabel.background: aquamarine rc.XmLabel.background:#70DB93 n In application code use a XColor data structure defined as typedef struct { unsigned long pixel; unsigned short red,green,blue; char flags; char pad; } XColor;\ n Named Color examples slide

Colorcells continued n There are 2 kinds of color cells in a colormap. u shared (readonly) u private(read/write) n Application clients can request a private cell to assign a color. If none are available they can choose a shared cell that is “close” to the desired color.

n private cells may be very limited and used up quickly. n Use shared cells when possible.

Using Shared Colorcells n First create pointers to two XColor structures. XColor colorcell; n Initialize with the values you want colorcell.red = 65535; colorcell.green=... n get the colormap cmap = DefaultColormap(display, DefaultScreen(screen));

Using Shared Colorcells n Make a library call to get the closest pixel value if ( XAllocColor( display, cmap, &colorcell) == 0 ) {/* failure*/} n The XAllocColor supports the shared cell strategy. It returns a pixel value that you can use. n If you prefer named colors (and you should use these to promote sharing) use XAllocNamedColor()

Example Uses XAllocNamedColor()

Getting info. n Because a “closest” will be chosen for you, you can use Colormap cmap; Xcolor color; color.red =... XQueryColor(display,cmap,&color); or XParseColor(display,cmap,65535,&color) or XLookupColor(display,cmap,name,&color,& exact) for information about what will happen

Allocating private cells n To allocate private color cells use XAllocColorCells ( ) library routine to allocate the cells. This should be checked for failure. n Then XStoreColor( ) or XStoreNamedColor( ) can be used to fill these cells. n private color cells should be freed when no longer needed with XFreeColors( ). DO NOT CALL with shared cells.

Standard ColorMaps n To promote maximum sharing X provides several standard color maps. These maps contain cells with preloaded values. n The root window usually loads a standard colormap at startup n Application using a standard colormap face colormap change effects and must take what they get.

Colormaps are resources n XCreateColormap( ) n XCopyColormap( ) are both ways to create new colormaps. Colormaps created by applications must be installed in order to be used and are destroyed on exit. n XInstallColormap( ) n XUninstallColormap( ) n XFreeColormap( )

Colormaps are not really private n Installed colormaps are a resource of the screen and if its resource id is discovered by other applications (XListInstalledColormaps( )) it can be used - but not altered if you fill all the cells) n Once installed it must be associated with windows.

Events n Applications can arrange to receive ColormapNotify events. These events notify the application of changes to the colormap in your windows.

Summary Applications draw into windows and pixmaps using pixel values. These values are relative to color cells that are defined in colormaps. Applications cannot assume any meaning about colors on a platform. X calls are used to generate pixel values corresponding to desired colors. Colors are specified as a combination of red green and blue values. Each color map cell contains a single rgb triplet. Colormap cells are scarse, so choosing the closest color values to the default colormap installed in the root window is a preferred technique. However applications can create and install their own private color maps. Changing colormaps on some platforms can create undesirable effects outside of the application window.

Summary Production code must do a lot of determination about the platform on which it is running before using library routines: the number of colormap cells, the default color map, the number of color planes ( not discussed with these slides) Xlib provides a variety of service functions for color, the most important being the ability to translate named colors into rgb triples.

Future studies n Students interested in color should look next into visual techniques and their support in X u color planes u support in X for applications that need to interpolate between colors for shading effects. n Production quality color code examples should be investigated. HAVE A GREEN DAY!