Download presentation
Presentation is loading. Please wait.
Published byMyrtle Bell Modified over 7 years ago
1
Chapter 8. Drawing Pixels, Bitmaps, Fonts, and Images Computer Graphics (spring, 2009) School of Computer Science University of Seoul
2
Bitmap and Fonts
3
Bitmap ● One bit per pixel. ● “mask” ● Drawing characters. ● Position: glRasterPos*() ● Drawing: glBitmap() ● Example: drawf.cdrawf.c ● Starting from lower-left corner. ● Byte-aligned.
4
Current Raster Position ● Set by glRasterPos*(). ● Transformed by modelview & projection matrices. (not the bitmap!) ● How to position in windows coords? ● To use orthogonal projection & identity modelview. ● To use glWindowPos(). (ver 1.4) – no clipping, etc.
5
Current Bitmap Color ● Set from the current color when glRasterPos*() is called!!! glColor3f(1.0, 1.0, 1.0); /* white */ glRasterPos3fv(position); glColor3f(1.0, 0.0, 0.0); /* red */ glBitmap(....);
6
Images
7
Pitfalls ● OpenGL doesn’t provide features to load/store various image formats. ● OpenGL doesn’t provide any feature related to image compression/decompression.
8
OpenGL Image Manipulation ● glReadPixels(): GPU mem CPU mem ● glDrawPixels(): CPU mem GPU mem ● glCopyPixels(): GPU mem GPU mem
9
glReadPixels() ● GPU mem CPU mem ● Which buffer to read from? glReadBuffer() ● Pixel format? Table 8-2Table 8-2 ● Pixel type? Table 8-3Table 8-3
10
Pixel Formats & Types ● Bits per pixel determined by the combination. ● For signed formats, negative values not used typically.: less precision. ● Limited valid pixel formats for “packed” types. (ver 1.2) ● GL_*_REV types for MS platform. (ver 1.2)
11
glDrawPixels() ● CPU mem GPU mem ● Which buffer to write to? glDrawBuffer() ● Example: image.cimage.c
12
glCopyPixels() ● GPU mem GPU mem ● Which buffer to write from and to? glReadBuffer*() and glDrawBuffer() ● No format and type required.
13
Imaging Pipeline
14
Pixel Packing & Unpacking ● How pixel data is written to and read from the CPU memory. ● Format + type.
15
Pixel-Storage Modes ● Issues ● Subimage ● Big/little endianendian ● Byte alignment ● Set by glPixelStore*().
16
Pixel-Transfer Operations ● Applied to image data while being transferred between CPU & GPU mems. ● Range of components, etc... ● glPixelTransfer*(), glPixelMap*()
17
glPixelZoom() ● Magnifying, reducing, and flipping images for rasterization. ● Example: image.cimage.c
18
Imaging Pipeline ● Fig. 8-4~8 Fig. 8-4~8
19
Reading and Drawing Pixel Rectangles
20
Fig. 8-10 & 11
21
Using Buffer Objects with Pixel Rectangle Data (advanced)
22
Buffer Objects ● OpenGL ver 1.5. ● Pixel data in GPU mem. ● Better performance. ● For advanced effects. ● Example: pboimage.c
23
Tips for Improving Pixel Drawing Rates
24
Imaging Subset (ver 1.2)
25
Imaging Subset ● Color lookup table ● contrast enhancement, filtering, image equalization ● Example: colortable.c ● Convolution ● Replaces each pixel with a weighted average of its neighboring pixels and itself. ● Blurring, sharpening, edge finding, etc. ● Example: convolution.c
26
Imaging Subset ● Color matrix transformation ● Linear transformations on pixel values ● Example: colormatrix.c ● Histogram ● Distribution of color values in an image. ● Example: histogram.c ● Minmax ● min/max pixel component values for a pixel rectangle. ● Example: minmax.c
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.