Pixmaps, Bitmaps and Images How X applications can create, draw, or process rasters,

Slides:



Advertisements
Similar presentations
X Ricardo A. Baratto NCL. Overview System overview X protocol X server Architecture Porting process XFree86 (device drivers)
Advertisements

OpenGL Open a Win32 Console Application in Microsoft Visual C++.
Coordinate System.
Software project Gnome Graphics Olga Sorkine Andrei Scharf Office: Schreiber 002, Web:
Graphics You draw on a Graphics object The Graphics object cannot directly be created by your code, instead one is generated when the method paintComponent.
Computer Graphics Tz-Huan Huang National Taiwan University (Slides are based on Prof. Chen’s)
Technology ICT Option: Data Representation. Data Representation In our everyday lives, we communicate with each other using analogue data. This data takes.
Data: Programming Design and Modularization IS 101Y/CMSC 101 Computational Thinking and Design Thursday, September 26, 2013 Marie desJardins University.
Next Generation MMI Requirements May 4, MMI - High Level Requirements run under UNIX and Windows NT (WNT) use a well defined ASCII definition for.
Parts From: Learning Media Design with Adobe CS3 Exercise 34.
GUI and Swing, part 2 The illustrated edition. Scroll bars As we have previously seen, a JTextArea has a fixed size, but the amount of text that can be.
Graphics CS 121 Concepts of Computing II. What is a graphic? n A rectangular image. n Stored in a file of its own, or … … embedded in another data file.
Raster Displays Images are composed of arrays of pixels displayed on a raster device. Two main ways to create images: –Scan and digitize an existing image.
Graphics Bitmaps Drawing characters glyphs and multicolor patterns.
Eleven colors and rasters. Color objects Meta represents colors with color objects You can create a color by saying: [color r g b] r: amount of red (0-255)
Sketchify Tutorial Graphics and Animation in Sketchify sketchify.sf.net Željko Obrenović
First Bytes - LabVIEW. Today’s Session Introduction to LabVIEW Colors and computers Lab to create a color picker Lab to manipulate an image Visual ProgrammingImage.
Eleven colors and rasters. Color objects Meta represents colors with color objects You can create a color by saying: [color r g b] r: amount of red (0-255)
CS 4731: Computer Graphics Lecture 21: Raster Graphics Part 2 Emmanuel Agu.
IAT 800 Lecture 8. Oct 13, Fall 2006IAT 8002 Outline  Programming concepts –BImage BFont –Creating XImage –Typography.
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.
Vector vs. Bitmap SciVis V
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.
OpenGL Pixel Operations, Bitmaps, Fonts and Images The Current Raster Position Current raster position: A position in window coordinates where the next.
1. 2  A computer is a device capable of storing data  in a format suited to the computer,  which is then processed by mathematical manipulation and.
Vector Graphics Making custom images. Raster vs. Vector Graphics In computer graphics, a raster graphics image, or bitmap, is a dot matrix data structure.
Bitmapped Images. Bitmap Images Today’s Objectives Identify characteristics of bitmap images Resolution, bit depth, color mode, pixels Determine the most.
XP Tutorial 7 New Perspectives on Microsoft Windows XP 1 Microsoft Windows XP Working with Graphics Tutorial 7.
Filtering (I) Dr. Chang Shu COMP 4900C Winter 2008.
19/4/ :32 Graphics II Syllabus Selection and Picking Session 1.
Guide to Assignment 3 Programming Tasks 1 CSE 2312 Computer Organization and Assembly Language Programming Vassilis Athitsos University of Texas at Arlington.
20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 16: Java Applets & AWT Fundamentals of Web Programming.
COMPUTER GRAPHICS Prepared by S.MAHALAKSHMI Asst. Prof(Sr) / SCSE VIT University.
1 Scrolling and Panning CIS 487/587 Bruce R. Maxim UM-Dearborn.
SDL Programming Introduction. Initialization 2  The first thing you must do is initialize SDL  int SDL_Init( SDL_INIT_EVERYTHING )  This will return.
 Bitmap: A bitmap is a rectangular array of 0s and 1s that serves as a drawing mask for a corresponding rectangular portion of the window.  Applications:
MIPS coding. SPIM Some links can be found such as:
CP104 Introduction to Programming File I/O Lecture 33 __ 1 File Input/Output Text file and binary files File Input/output File input / output functions.
Variables and Objects, pointers and addresses: Chapter 3, Slide 1 variables and data objects are data containers with names the value of the variable is.
Graphics Systems and OpenGL. Business of Generating Images Images are made up of pixels.
Computer Science 112 Fundamentals of Programming II Graphics Programming.
Using the JImageViewer classes. JImageViewer classes JImageViewer class JImageViewer class ImagePanel class ImagePanel class Image class Image class.
Text-Mode Programming Question #1 What are the three levels of access to the video display when writing characters on the screen in text mode?
Introduction to Interactive Media Interactive Media Components: Text.
Information Processes and Technology Multimedia: Graphics.
Graphics and Images Graphics and images are both non-textual information, that can be displayed and printed. These images may appear on screen as well.
Introduction to Raytracing Raytracing Introduction (from Wikipedia) In computer graphics, ray tracing is a technique for generating an image by tracing.
CS1372: HELPING TO PUT THE COMPUTING IN ECE CS1372 Some Basics.
Project Two Adding Web Pages, Links, and Images Define and set a home page Add pages to a Web site Describe Dreamweaver's image accessibility features.
10H Interrupt. Option 0H – Sets video mode. Registers used: – AH = 0H – AL = Video Mode. 3H - CGA Color text of 80X25 7H - Monochrome text of 80X25 Ex:
The Cursor The user only thinks it is under his control.
Words. Characters and Strings Character –A single character inside of single quotes char letter = 'A' ; char digit = '0' ; – Strings Zero or more character.
Java and C++ Transitioning. A simple example public class HelloWorldApp { public static void main(String[] args) { //Display the string. System.out.println("Hello.
Guide to Assignment 3 and 4 Programming Tasks 1 CSE 2312 Computer Organization and Assembly Language Programming Vassilis Athitsos University of Texas.
Resources & Bitmaps Adding clip art to your application.
RASTERIZING SHAPES IN PHOTOSHOP RASTERIZE: A process in Photoshop of converting a vector image into a bitmap (or raster) image VECTOR: A vector image is.
Texture Mapping What is texture mapping? - a method for adding detail, surface texture (a bitmap or raster image), or color to a computer-generated graphic.
Guilford County SciVis V104.03
Processing == Java + Extra Utilities Processing Adds: – Drawing functions – Text and font manipulations – Image and video – 3D transformations – Keyboard.
Binary IO Writing and Reading Raw Data. Files Two major flavors of file: Text Binary.
Unit 2.6 Data Representation Lesson 3 ‒ Images
Representation of image data
What is a Function Expression?
Computer Graphics Lecture 3 Computer Graphics Hardware
X Programming with Xlib
Microprocessor and Assembly Language
This Week: Tkinter for GUI Interfaces Some examples
Outline Image formats and basic operations Image representation
Project 1: Into Space! CG Concepts Needed
OpenGL program.
Presentation transcript:

Pixmaps, Bitmaps and Images How X applications can create, draw, or process rasters,

Rasters n Rasters are rectangular areas of pixels. X represents rasters as – Pixmaps : X resources on which one can draw. – Bitmaps : n pixmaps with values of 1 bit n Text files defining an array of bits – Images : data structures that can be drawn into windows or pixmaps.

Pixmaps n A pixmap is a drawable that has – width and height – depth – an associated screen n A pixmap is like a window – coordinates with (0,0) being upper left – sizes expressed in pixels

Pixmaps and Windows n Pixmaps differ from windows – Some procedures do not apply to pixmaps n XClearArea( ) does not clear a pixmap but instead to clear an area one uses XFillRectangle( ) to set all pixels to aknown value. n Pixmaps are drawn into windows, not mapped to the screen. – Pixmaps have no borders. – Pixmaps do not belong to a widget hierarchy as do windows.

Pixmaps vs Windows n Events cannot originate from pixmaps, only from the windows into which they are drawn.

Pixmaps n Three functions are important: create – XCreatePixmap( Display* display, – Drawable screen, – unsigned int width, – unsigned int height, – unsigned int depth); n The screen parameter must represent some existing Drawable, a window or pixmap.

Pixmaps n Three functions are important: destroy – XFreePixmap(display,pixmap) ; if an application no longer needs a pixmap

Pixmaps n Three functions are important: inquire – Status XGetGeometry(Display* display, – Drawable drawable, – Window *root, – int *x, int *y, – unsigned int *border_width, – int *depth) the pointers return the information and is useful when the drawable is a pixmap.

Bitmaps n A bitmap is a Pixmap with depth 1 or n a text file containing ASCII information that defines an array of bits. n XReadBitmapFile ( ) to create a bitmap from a file n XWriteBitmapFile( ) to write a bitmap file.

Bitmap file format #define arrow_width 16 #define arrow_height 16 #define arrow_x_hot 12 #define arrow_y_hot 1 static char arrow_bits[ ] = { 0x00, 0x00, 0x00, 0x10, … };

Reading the bitmap file n int status; status =XReadBitmapFile(display,drawable, filename, &width,&height, &pixmap, &x_hot, &y_hot); which creates a bitmap and returns it in the pixmap parameter.

An example /* label_pixmap.c */ #include #include "btbuxton.xbm" XtAppContext context; Widget toplevel, label;

An example unsigned int get_depth(Widget w) /* gets the depth of the display holding w. */ { Window r; unsigned int x,y,wd,ht,bw,depth; XGetGeometry(XtDisplay(w), RootWindowOfScreen(XtScreen(toplevel)), &r,&x,&y,&wd,&ht,&bw,&depth); return depth; }

An example main(int argc,char *argv) { Arg al[10]; int ac; int foreground,background; Pixmap pix; unsigned int depth; toplevel = XtAppInitialize(&context, "",NULL,0,&argc,argv,NULL,NULL,0); /* create the label */ ac=0; label=XmCreateLabel(toplevel,"label",al,ac); XtManageChild(label);

/* get colors of label */ ac=0; XtSetArg(al[ac], XmNforeground, &foreground); ac++; XtSetArg(al[ac], XmNbackground, &background); ac++; XtGetValues(label, al, ac); /* get the depth so pixmap can be created. */ depth=get_depth(toplevel); /* create the pixmap */ pix=XCreatePixmapFromBitmapData(XtDisplay(toplevel), RootWindowOfScreen(XtScreen(toplevel)), btbuxton_bits,btbuxton_width,btbuxton_height, foreground,background,depth);

/* set appropriate label resources to * attach the pixmap to the label */ ac=0; XtSetArg(al[ac], XmNlabelType, XmPIXMAP); ac++; XtSetArg(al[ac], XmNlabelPixmap, pix); ac++; XtSetArg(al[ac], XmNshadowThickness, 4); ac++; XtSetValues(label, al, ac); XtRealizeWidget(toplevel); XtAppMainLoop(context); }

Another Example: Pixmap to Window. /* get the current fg and bg colors. */ ac=0; XtSetArg(al[ac], XmNforeground, &fc); ac++; XtSetArg(al[ac], XmNbackground, &bc); ac++; XtGetValues(drawing_area, al, ac); depth=get_depth(drawing_area); p=XCreatePixmapFromBitmapData( XtDisplay(drawing_area), XtWindow(drawing_area),btbuxton_bits, btbuxton_width,btbuxton_height, fc, bc, depth);

Another Example: Pixmap to Window. /* Draw the Pixmap in the drawing area */ XCopyArea(XtDisplay(drawing_area), p,XtWindow(drawing_area),gc,0,0, btbuxton_width, btbuxton_height, 100,100 ); /* Free up resources no longer needed */ XFreePixmap(XtDisplay(drawing_area),p);

Images n X provides support for image manipulation n Images are typically large – 512x512 pixel image with 8 bit pixels =.25M n Images must be communicated to the client so go through the X protocol (network?) and are thus slow. n Xlib must translate for different forms of clients (for example big endian image and little endian clients)

Images n Color maps are a problem. Many times one must translate pixel values from the image into values obtained from color cell allocation before the image is displayed.

XImages n XImage is an X datatype (struct) accompanied by formats – XYBitMap image format – XYPixMap image format – ZPixmap image format (organized as an array of pixel values, called pixel mode images) n input/output is binary i/o of objects of this type.

Example lines of code format = XYPixmap; bitmap_pad = 32; image = XCreateImage( display, DefaultVisual(display,screen), depth, format,0,0,width,height,bitmap_pad,0); newimage = XSubImage(image,x,y,width,height); pixel = XGetPixel(image, x,y); status = XPutPixel(image,x,y,pixel); XPutImage(display,drawable,gc,image,src_x,src_y,dest_x dest_y,width,height);

Tools n Lots of tools to generate bitmaps – bitmap n and to convert formats – bmtoa – atobm n and between other image formats.