Drawing Pixel, Bitmap, Image. Bitmap Bitmap: Pixel 당 1 bit (0/1) 의 array Bitmap 색상 : bitmap 1 에 대응하는 frame buffer 의 색상은 현재 raster color 로 설정된다. bitmap.

Slides:



Advertisements
Similar presentations
Vertex Buffer Objects, Vertex Array Objects, Pixel Buffer Objects.
Advertisements

©Zachary Wartell, UNCC9/28/ :30 AM 1 Overview of OpenGL Revision: 1.2 Copyright Professor Zachary Wartell, University of North Carolina All Rights.
Computer Graphics Tz-Huan Huang National Taiwan University (Slides are based on Prof. Chen’s)
Graphics Pipeline.
Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction.
Computer Graphics(Fall 2003) COMS 4160, Lecture 7: OpenGL 3 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
Computer Graphic Creator: Mohsen Asghari Session 2 Fall 2014.
OpenGL Texture Mapping
Objectives Introduce OpenGL buffers and read/write Introduce OpenGL buffers and read/write Introduce texture mapping Introduce texture mapping Introduce.
Chapter 7. Imaging with openGL & 22 Presented by Garrett Yeh.
OpenGL Son of the Survival Guide. Last Time on OpenGL Windowing … glut Rendering Primatives Transformations Projections State Management.
Buffers Mohan Sridharan Based on slides created by Edward Angel 1 CS4395: Computer Graphics.
Buffers Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
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.
Computer Graphics Ben-Gurion University of the Negev Fall 2012.
Introduction to OpenGL (Part 3) Ref: OpenGL Programming Guide (The Red Book)
CS 4731: Computer Graphics Lecture 21: Raster Graphics Part 2 Emmanuel Agu.
OpenGL Pixel Operations, Bitmaps, Fonts and Images The Current Raster Position Current raster position: A position in window coordinates where the next.
CSE (Notre Dame) Computer Graphics Lecture 16 A Simple Draw Image Example More Texture Mapping Simple OpenGL Image Library (SOIL) Transparency &
Picking. What is picking? Selecting an object on the screen What does this require? –Get Mouse Location –Compute what objects are rendered at the position.
 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:
Tools for Raster Displays CVGLab Goals of the Chapter To describe pixmaps and useful operations on them. To develop tools for copying, scaling, and rotating.
Texture Mapping + Texture Object = Texture Mapped Object.
Texture Mapping. Scope Buffers Buffers Various of graphics image Various of graphics image Texture mapping Texture mapping.
Computer Graphics Ben-Gurion University of the Negev Fall 2012.
COMPUTER GRAPHICS Hochiminh city University of Technology Faculty of Computer Science and Engineering CHAPTER 8: Texture Mapping.
ECSE-4750 Computer Graphics Fall 2004 Prof. Michael Wozny TA. Abhishek Gattani TA. Stephen
Imaging and Raster Primitives Vicki Shreiner. 2 Jobs Andrew Giles Andrew Giles Chuck Fultz Chuck Fultz SIGGraph - SIGGraph.
2002 by Jim X. Chen: 1 So far, we only concerned with the rendering of geometric data. Two other important classes of data:
Graphics Systems and OpenGL. Business of Generating Images Images are made up of pixels.
Texture Mapping Fall, Textures Describe color variation in interior of 3D polygon  When scan converting a polygon, vary pixel colors according.
Texture Mapping in OpenGL. Texture Mapping Imaging we are “pasting” a picture onto a model  Which part of the picture will be pasted onto which part.
Texture Mapping Drawing Pictures on Polygons. Texture Mapping.
Discrete Techniques Chapter 7 Begun February 22, 2005 Finished April 26, 2005.
Review of OpenGL Basics
111/17/ :24 UML Solution Involves Selection of Discrete Representation Values.
2 COEN Computer Graphics I Evening’s Goals n Discuss displaying and reading image primitives n Describe texture mapping n Discuss OpenGL modes and.
Introduction to OpenGL  OpenGL is a graphics API  Software library  Layer between programmer and graphics hardware (and software)  OpenGL can fit in.
Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic Light Source.
OpenGL Architecture Display List Polynomial Evaluator Per Vertex Operations & Primitive Assembly Rasterization Per Fragment Operations Frame Buffer Texture.
Draw a Simple Object. Pixel pipeline Vertex pipeline Course Map Transformation & Lighting Primitive assembly Viewport culling & clipping Texture blending.
OpenGL Programming Guide : Texture Mapping Yoo jin wook Korea Univ. Computer Graphics Lab.
Chap 11. Raster Graphics in OpenGL. Chap 11. Raster Graphic in OpenGL2 Content Draw bitmap image Use bitmap fonts Draw color images Read and copy color.
Computing & Information Sciences Kansas State University Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.
Computer Graphics Bing-Yu Chen National Taiwan University.
Buffers Computer Graphics I, Fall 2010.
Buffers, Compositing and Blending Week 8 David Breen Department of Computer Science Drexel University Based on material from Ed Angel, University of New.
Details of Texture Mapping Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, December 1, 2003.
Buffers. 2 Objectives Introduce additional OpenGL buffers Learn to read and write buffers Learn to use blending.
The Framebuffer Hyun-Chul Cho. HyunChul Cho - KUCG -2 Buffer Goal of a graphics program Draw pictures on the screen Screen Rectangular array.
Tan-Chi Ho, CGGM Lab., CSIE of NCTU Pixel Operations and Buffers.
CS425 © 2003 Ray S. Babcock Pixels and Bitmaps ● OpenGL allows us to work directly with bits and groups of bits, or pixels, which flow down a parallel.
Texture Mapping CEng 477 Introduction to Computer Graphics.
CSC Graphics Programming Budditha Hettige Department of Statistics and Computer Science.
Chapter 8. Drawing Pixels, Bitmaps, Fonts, and Images Computer Graphics (spring, 2009) School of Computer Science University of Seoul.
Buffers Ed Angel Professor Emeritus of Computer Science
Texture Mapping Fall, 2016.
Draw a Simple Object.
COIS712/ECOM708/COIS800 Chapter 4 Graphics Output Primitives (Part II)
Computer Graphics, Lee Byung-Gook, Dongseo Univ.
Introduction to Computer Graphics with WebGL
Geb Thomas Adapted from the OpenGL Programming Guide
Computer Graphics, Lee Byung-Gook, Dongseo Univ.
Class 26 more textures environmental textures Color ramps
Computer Graphics, Lee Byung-Gook, Dongseo Univ.
Computer Graphics Buffers
3D Game Programming Texture Mapping
Buffers Ed Angel Professor Emeritus of Computer Science
Class 27 more textures environmental textures Color ramps
Programming Textures Lecture 15 Fri, Sep 28, 2007.
Presentation transcript:

Drawing Pixel, Bitmap, Image

Bitmap Bitmap: Pixel 당 1 bit (0/1) 의 array Bitmap 색상 : bitmap 1 에 대응하는 frame buffer 의 색상은 현재 raster color 로 설정된다. bitmap display 위치 : 현재 raster 위치에 상 대적으로 결정. 현재 raster 위치 설정 : glRasterPos*() 함수 Bitmap 의 draw: glBitmap() 함수

Bitmap Data Bitmap data 는 아래에서 위 방향으로 MSB first 로 정 의된다.

Bitmap Data GLubyte rasters[24] = { 0xc0, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0xff, 0x00, 0xff, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0xff, 0xc0, 0xff, 0xc0}; Bitmap의 size는 16x12이므로 2개의 unsigned byte가 하나의 row를 구성 Data는 아래의 row 부터 위로 정의한다.

Raster 위치 설정 glRasterPos{234}{sifd}(x, y, z, w); glRasterPosfv {234}{sifd}(coords); 명기한 좌표값은 vertex 좌표와 동일하게 변환된다. raster position data 구성 = three window coordinates (x, y, z) + clip coordinate w value + an eye coordinate distance + a valid bit + associated color data + texture coordinates

bitmap 의 draw glBitmap(Glsizei width, Glsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte * bitmap) xorg, yorg: Bitmap 의 원점. 현재의 raster position 과 bitmap 의 (xorg, yorg) 위치를 일치 시킨다.xorg, yorg: Bitmap 의 원점. 현재의 raster position 과 bitmap 의 (xorg, yorg) 위치를 일치 시킨다. xmove, ymove: bitmap 이 draw 된후 raster position 이 이동되는 offsetxmove, ymove: bitmap 이 draw 된후 raster position 이 이동되는 offset 좌표의 모든 단위는 pixel 임 좌표의 모든 단위는 pixel 임

bitmap 의 draw 원점이 (0,0) 이므로 글자의 baseline 은 0 의 위치 xOffset 이 11 이므로 다음의 F letter 는 11 위치 offset 되어 draw 된다. Xoffset 이 11.5 로 지정되면 F 글자 사이의 간격은 1 또는 2 pixel 사이에 위치하게 된다.

bitmap 의 색지정 glColor3f(1.0, 1.0, 1.0); /* white */ glRasterPos3fv(position); glColor3f(1.0, 0.0, 0.0); /* red */ glBitmap(....); 위의 code에서 bitmap은 white color로 그려진다. GL_CURRENT_RASTER_COLOR is set when glRasterPos() is called

Image Image(Pixmap): more information (colors) for each pixel. For example, RGBA pixel Image Source - 사진을 scanning - frame buffer - 프로그램으로 memory 에 생성

Pixel Data 의 Read/Draw/Copy glReadPixels(): framebuffer 에서 읽어 processor memory 에 data 저장 glDrawPixels(): processor memory 의 pixel data 를 framebuffer 로 glCopyPixels(): Framebufferdml pixel 을 frame buffer 로 복사. glDrawPixels()/glCopyPixels() 함수에서 raster 위치는 glRasterPos*() 로 지정된다.

glDrawPixels(width, height, format, type, GLvoid *pixels); - From : 프로세서 memory 의 array pixels - To : framebuffer 에 현재의 raster position 에서 width 와 height 의 사각형 크기로 - format : memory 에 있는 pixel 의 formats - type : memory 에 있는 pixel component 의 data type - raster position 의 설정은 glRasterPos*() 함수를 사용 - 쓰여질 framebuffer 는 glDrawBuffer(GL_BACK) 함수 를 사용. 이 함수에 인수로는 GL_BACK, GL_FRONT, GL_LEFT, GL_RIGHT, GL_FRONT_LEFT 등을 사용

GLubyte checkImage[ImageHeight][ImageWidth][3] glClear(GL_COLOR_BUFFER_BIT); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glRasterPos2i(0, 0); glDrawPixels(ImageWidth, ImageHeight, GL_RGB, GL_UNSIGNED_BYTE, checkImage); glFlush(); 예제 Code

Pixel Reading 함수 : Frame buffer 에서 pixel data 를 읽어 memory 로 저장  glReadPixels(x, y, width, height, format, type, GLvoid *pixels);  - From : framebuffer whose lower-left corner (x,y) and dimensions are width and height (pixel 단위 )  - To : pixels 로 지정한 memory 로 framebuffer 의 pixel 을 저장 - Format : frame buffer 에 있는 읽혀질 pixel data 의 formats. GL_RGB, GL_RGBA, GL_RED, etc - type: 저장되는 pixel 의 data type. GL_INT (4 byte), GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT - 일혀질 framebuffer 는 glReadBuffer(GL_BACK) 함수를 사용하여 지정한다.

Pixel Copying: glCopyPixels 함수 () glCopyPixels(x, y, width, height, buffer); - From : framebuffer rectange whose lower-left corner is at (x,y) and dimensions are width and height -To : framebuffer with its lower-left corner at the current raster position - buffer : GL_DEPTH, GL_STENCIL or GL_COLOR -data 가 memory 에 저장되지 않으므로 format 과 type 은 필요 없다. - source buffer 는 glReadBuffer() 함수로 destination buffer 는 glWriteBuffer() 함수로 지정

Image 처리 Pipeline

glDrawPixels()/glReadPixels() 의 pipeline glDrawPixels: Processor Memory -> Pixel Stroage Mode -> Pixel-Transfer Operation -> Raterization ( including Pixel Zoom) -> Per- Fragment Operation -> framebuffer glReadPixels: framebuffer -> Pixel-Transfer Operation -> processor memory

glCopyPixels() pipeline

glBitmap pipeline

glTexImage*(), glTexSubImage*(), glGetTexImage()

glCopyTexImage*()/glCopyTexSubImage*()

Pixel Storage Mode 의 control glPixelStore{if}() 함수를 사용 Byte Swapping LSB ordering Row or pixel skipping 작업

void glPixelStore{if}(GLenum pname, TYPE param); pname: unpack 일때 GL_UNPACK_xxx 로 ㅔ pack 일때 GL_PACK_XXX 로 적용될 작업 지 정 GL_UNPACK_SWAP_BYTES: multibyte color component ( 각각의 R, G, B 네에서 ) depth component, color index, stencil index 안 에서 byte 순서를 바꾼다. RGBA 의 순서를 바꾸지는 않는다.

GL_UNPACK_LSB_FIRST: param=GL_TRUE 일때, 한 byte 안에서 bit 의 순서를 바꾼다 GL_UNPACK_ROW_LENGTH: 한 row 에 있 는 actual pixel 의 수를 정의. 0 일 때는 glDrawPixels() 등의 함수에서 지정한 width 값 으로 설정됨. GL_UNPACK_SKIP_ROWS: skip 될 row 의 수 를 설정 GL_UNPACK_SKIP_PIXELS: skip 될 pixels 의 수를 설정

GL_UNPACK_ALIGNMENT: 각각 pixel row 의 시작을 나타내는 alignment requirement 를 나 타냄 (1, 2, 4, 8 중 하나 사용 ) 5 pixel wide 의 RGB (3 bytes) data row 당 : 5*3 =15 byte 소요됨 빠른 access 를 위하여 alignment 를 4 로 설정 하고 각 row 를 16 byte memory 에 저장

PnameTypeInitial ValueValid Range GL_PACK_SWAP_BYTESBooleanfalsetrue or false GL_PACK_SWAP_BYTESBooleanfalsetrue or false GL_PACK_ROW_LENGTHinteger0[0,) GL_PACK_SKIP_ROWSinteger0[0,] GL_PACK_SKIP_PIXELSinteger0[0,] GL_PACK_ALIGNMENTinteger41, 2, 4, or 8 GL_UNPACK_SWAP_BYTESBooleanfalsetrue or false GL_UNPACK_LSB_FIRSTBooleanfalsetrue or false GL_UNPACK_ROW_LENGTHinteger0[0,] GL_UNPACK_SKIP_ROWSinteger0[0,] GL_UNPACK_SKIP_PIXELSinteger0[0,] GL_UNPACK_ALIGNMENTinteger41, 2, 4, or 8

Pixel Transfer Operation - Color biasing, scaling, mapping …. 등을 수행 : Color, color index, depth, stencil pixel 에 대하 여 적용됨. -glDrawPixels, glReadPixels, glCopyPixels, glTexImage1D, and glTexImage2D 함수에 영향을 줌.glDrawPixelsglReadPixelsglCopyPixels glTexImage1DglTexImage2D - void glPixelTransfer{if}(GLenum pname, TYPE param);

void glPixelTransfer{if}(GLenum pname, TYPE param); 함수 GL_MAP_COLOR, GL_MAP_STENCIL: TRUE/FALSE MAPPING 의 적용여부 GL_RED_SCALE, GL_ALPHA_SCALE, GL_DEPTH_SCALE: 색의 component 에 곱하여지는 factor GL_RED_BIAS, etc: 색의 component 에 더해지는 값

Color Pixel 에 적용 - 각각의 color component 는 SCALE factor 로 곱 해진 후 BIAS factor 가 더해진다. 즉 red component 는 GL_RED_SCALE 로 곱해진 후 GL_RED_BIAS 값이 더해진다. 그후 [0,1] 범위 로 clamp 된다. - GL_MAP_COLOR 가 GL_TRUE 로 설정됬을 때, GL_PixelMap 에 의하여 설정된 color-to-color map 에 의하여 값이 보정된다.

Pixel Mapping - void glPixelMap{ui us f}(GLenum map, Lint mapsize, const TYPE *values); - Map: 적용될 map 의 종류, GL_PIXEL_MAP_R_TO_R, GL_PIXEL_MAP_S_TO_S GL_PIXEL_MAP_I_TO_I, GL_PIXEL_MAP_I_TO_R GL_PIXEL_MAP_A_TO_A 등을 지정 - Mapsize: map 의 row 크기 - Values: mapping table

GL_float lut[256]; for (I=0; I < 256; ++I) lut[I]=pow(i/255.0, 1.0/1.7); glPixelTransferi(GL_MAP_COLOR, GL_TRUE); glPixelMap(GL_PIXEL_MAP_R_TO_R, 256, lut); glPixelMap(GL_PIXEL_MAP_G_TO_G, 256, lut); glPixelMap(GL_PIXEL_MAP_B_TO_B, 256, lut);

Pixel Zooming  Pixel 을 확대, 축소, Flipping 등을 할 수 있다. glDrawPixels, glCopyPixels 등에 적용됨.  void glPixelZoom(GLfloat zoomx, GLfloat zoomy);  glPixelZoom(-1.0, 1.0) // image 는 수평 으로 flip