200 likes | 346 Views
CS 470 Introduction to Computer Graphics. Bitmaps & Images. Bitmaps and Images. Some objects that we might draw are not geometry These objects are images and consist of bitmaps You can’t (for the most part) manipulate bitmaps the same way you manipulate geometry. Bitmaps and Images.
E N D
CS 470Introduction toComputer Graphics Bitmaps & Images
Bitmaps and Images • Some objects that we might draw are not geometry • These objects are images and consist of bitmaps • You can’t (for the most part) manipulate bitmaps the same way you manipulate geometry.
Bitmaps and Images • OpenGL pipeline Geometry Rasterization Display Bitmaps/ Pixels
Bitmaps and Images void glBitmap(GLsizei r, GLsize c, GLfloat dx, GLfloat dy, GLfloat xn, GLfloat yn, GLubyte *array); Creates an r by c image from the bitmap array located at dx, dy from the current raster position. xn, yn are the new values of rasterposition.
Bitmaps and Images • Sample code – GLubyte wb[2] = {0x00, 0xff}; GLubyte check[512]; int i, j; for[i=0; i<64, i++) for (j=0; j<8, j++); check[i*8 +j] = wb[(i/8+j)%2]; glBitmap(64, 64, 0.0, 0.0, 0.0, 0.0, check); from Angel, 2002
Bitmaps and Images void glLogicOp(Glenum logop); Determines the logicial operation used to display the image over existing display. Default is to replace the existing pixel with the image pixel Must enable with glEnable(GL_COLOR_LOGIC_OP);
Bitmaps and Images • Some logic operations • GL_CLEAR • GL_COPY source • GL_NOOP destination • GL_SET set regardless • GL_OR s OR d • GL_XOR s XOR d
Bitmaps and Images void glDrawPixels(GLsizei w, GLsizei h, GLenum format, GLenum type, void *array); Draws images from pixels defined in array at current raster position. Format can be GL_RGB, GL_RGBA, GL_RED, …, GL_DEPTH_COMPONENT
Bitmaps and Images void glReadPixels(GLint x, GLsize y, GLsize w, GLsize h, GLenum format, GLenum type, void *array); Takes a snapshot of a w by h rectangle at x, y and stores it in an array;
Bitmaps and Images void glCopyPixels(GLint x, GLint y, GLsizei w, GLsizei h, GLenum buffer); copies a w by h rectangular image from buffer at x, y and puts it at current raster position.
Bitmaps and Pixels void glReadBuffer(GLenum buffer); void glDrawBuffer(GLenum buffer); Determines the buffer used for reading or drawing respectively.
Bitmaps and Images • Buffers can be • GL_FRONT • GL_BACK • GL_FRONT_AND_BACK • GL_RIGHT_FRONT • GL_LEFT_FRONT • GL_RIGHT_FRONT • GL_LEFT_FRONT • …
Bitmaps and Images • Pixel mapping • alters pixel values according to a map • allows you to make color adjustments • allows you to create false colors
Bitmaps and Images void glPixelTransfer{i|f}(GLenum name, Type value); Defines how pixel mapping can occur i.e. – glPixelTransferi(GL_MAP_COLOR, GL_TRUE);
Bitmaps and Images void glPixelMap{us|ui|f}v(GLenum map, GLint size, TYPE *array); Defines a map for translating pixel to new pixel values. Map can be GL_PIXEL_MAP_I_TO_R {G|B} or …R_TO_R, B_TO_B, G_TO_G
Bitmaps and Images void glPixelZoom(GLfloat sx, sy); scales pixels in bitmap by factors sx and sy. sx, sy > 1 – enlarge sx,sy < 1 – reduce negative sx, sy invert the image
Bitmaps and Images void gluScaleImage(GLenum format, GLint win, GLint hin, GLenum typein, void *imagein, GLint wout, GLint hout, GLenum typeout, void *imageout); Scales an image/bitmap from imagein and writes it to imageout.
Bitmaps and Images • Image processing