1 / 14

Lecture 13 Pixels, Bitmaps, Fonts, Images

Lecture 13 Pixels, Bitmaps, Fonts, Images. Bitmaps and Fonts. 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: The most application of bitmaps in OpenGL is to display Fonts on the screen.

prue
Download Presentation

Lecture 13 Pixels, Bitmaps, Fonts, Images

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 13Pixels, Bitmaps, Fonts, Images

  2. Bitmaps and Fonts • 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: The most application of bitmaps in OpenGL is to display Fonts on the screen. • Raster Position: Points to a location on the screen where the bitmap is drawn(Lower Left Corner). Note: Raster Position is affected by MODEL_VIEW matrix • Use glRasterPos to set Raster Position

  3. Bitmaps and Fonts • Drawing Bitmaps: • First setup the position that you want to draw using glRasterPos2i(x, y). • Then use glBitmapas follow to draw the bitmap: glBitmap(width, height, xbo, ybo, xbi, ybi, const GLubyte *bitmap)

  4. Fonts and Display Lists • Display lists are very useful when used with fonts. • A new list can be generated for each character and be called correspondingly when needed. • By using display lists, you can define a function that takes a text as input and prints out the input on screen.

  5. Images • Reading, Writing, and Copying Pixel: • Usethree basic commands that manipulate image data • glReadPixels() - Reads a rectangular array of pixels from the framebuffer and stores the data in processor memory. • glDrawPixels() - Writes a rectangular array of pixels from data kept in processor memory into the framebuffer at the current raster position specified by glRasterPos*(). • glCopyPixels() - Copies a rectangular array of pixels from one part of the framebuffer to another. This command behaves similarly to a call to glReadPixels() followed by a call to glDrawPixels(), but the data is never written into processor memory.

  6. Diagram of Pixel Data Flow

  7. Reading Pixel Data from Frame Buffer to Processor Memory • glReadPixels(GLintx, GLint y, GLsizei width, GLsizei height, GLenumformat, GLenum type, GLvoid*pixels) Reads pixel data from the framebuffer rectangle whose lower-left corner is at (x, y) and whose dimensions are width and height and stores it in the array pointed to by pixels. Note: If you are using double-buffer, you have to specify which buffer are you using front buffer or back buffer.

  8. Writing Pixel Data from Processor Memory to Frame Buffer • void glDrawPixels(GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels) Draws a rectangle of pixel data with dimensions width and height. The pixel rectangle is drawn with its lower-left corner at the current raster position. format and type have the same meaning as with glReadPixels(). Note: If the current raster position is invalid, nothing is drawn, and the raster position remains invalid.

  9. Pixel Packing and Unpacking • Packing and unpacking refer to the way that pixel data is written to and read from processor memory. • During Packingand Unpacking, we are enable to manipulate the data read. • Such modifications consist of: • Controlling Pixel-Storage Modes • Pixel-Transfer Operations • Pixel Mapping

  10. Controlling Pixel Storage Modes • Packing and unpacking refer to the way that pixel data is written to and read from processor memory. • Sometimes you may be dealing with packing/unpacking a sub-image instead of the whole image. • In such conditions, controlling byte alignment may be very useful: • Different machines have different byte orders • Some machines have special hardware that works only if data is aligned in 2, 4 or 8 byte boundaries in processor memory. • In such cases, we use glPixelStoreto align the data

  11. Controlling Pixel Storage Modes

  12. Controlling Pixel Storage Modes

  13. Pixel Transfer Operations • Before the data is written to frame-buffer or processor memory, OpenGL can perform several operations on it. • The range of a component can be changed, e.g. you may want to change the range of red component to be other than [0,1] • Or, could be that the data you are using comes from a different graphic system which stores the RGB components in a different range rather than [0,1] • In these situations use glPixelTransfer function in order to transform the data as you need.

  14. QUESTIONS?

More Related