






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An introduction to manipulating raster graphics, specifically pixmaps, through various operations such as copying, comparing, and scaling. It also covers rotating images and combining pixmaps pixel-wise. Code snippets for an rgbpixmap class and discusses alpha channel and image blending.
Typology: Slides
1 / 12
This page cannot be seen from the preview
Don't miss anything!







Computer Graphics Raster Graphics: Manipulating Images
n Pixmap = rectangular array of numerical values n Pixmap copied to frame buffer = rendered n Change frame buffer entry = onscreen picture changes n Each pixel location has fixed number of bits (color depth) n Example: if color depth is b bits, can store up to 2b^ values
n Data types for pixmaps n Bitmap: 1 bit, on or off n Gray scale: one byte, values 0- n RGB: 3 bytes (red, green, blue) n RGBA: 4 byte (red, green, blue, alpha) n Declaration of RGB triple:
class RGB{ public: unsigned char r, g, b; };
n OpenGL convention: pixmap (bottom to top, left to right) n Add draw, read and copy methods (which use openGL)
Class RGB{ public: unsigned char r, g, b;
RGBpixmap( ); // constructor void setPixel(int x, int y, RGB color); RGB getPixel(int x, y); void draw( ){ glDrawPixels(nCols, nRows, GL_RGB, GL_UNSIGNED_BYTE, pixel); void read( ){glReadPixels(x, y, nCols, nRows, GL_RGB, GL_UNSIGNED_BYTE, pixel);
n Scaling: want a pixmap that has s times more pixels in x, y n s > 1: enlargement n s < 1: reduction (information is lost!)
n openGL scaling: n glPixelZoom(float sx, float sy) n Sets scale factors for drawing pixmaps n Note: pixmaps not scaled, pictures drawn are scaled
Original Pixmap element s > 1^ s < 1
Original Pixmap element
n Sets scale factors for subsequent glDrawPixels command n Scaling is about current raster position, pt. n Pixel row r and column c of pixmap n Drawn as rectangle with bottom left current screen coordinates n Draws (pt.x + sx*r, pt.y + sy.c)
n Copy one pixmap to another doing matrix transposes
n affine transform of pixmap points to get new pixmap
n Generalized weighting: n C[i][j] = (1-f).A[i][j] + f.B[i][j] n Example: n A = (14, 246, 97), B = (82, 12, 190), f = 0. n C = (27, 199, 115) = 0.8 A + 0.2 B n Question: How to dissolve image A into B? n Raster demo!!
n Even more generalized weighting = blending/compositing n Blending: n draw partially transparent image over another n Add 4th^ component, alpha value (A) to RGB n Interpretation: alpha specifies how opaque each pixel is n Transparent (A = 0), Total opacity (A = 255) n Alpha most frequently used in scaling colors n Alpha channel: series of alpha values in a pixmap
class RGB{ public: unsigned char r, g, b,a; };