1.8. 绘制图片 Drawing Images

2024-01-08 22:08
文章标签 图片 绘制 1.8 images drawing

本文主要是介绍1.8. 绘制图片 Drawing Images,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

1.8. 绘制图片 Drawing Images


As mentioned previously, OpenGL has a great deal of support for drawing images in addition to

its support for drawing 3D geometry. In OpenGL parlance, images are called PIXEL RECTANGLES.

The values that define a pixel rectangle start out in application-controlled memory as shown in

Figure 1.1 (11). Color or grayscale pixel rectangles are rendered into the frame buffer with

glDrawPixels, and bitmaps are rendered into the frame buffer with glBitmap. Images that are

destined for texture memory are specified with glTexImage or glTexSubImage. Up to a point, the

same basic processing is applied to the image data supplied with each of these commands.

1.8.1. Pixel Unpacking

OpenGL reads image data provided by the application in a variety of formats. Parameters that

define how the image data is stored in memory (length of each pixel row, number of rows to

skip before the first one, number of pixels to skip before the first one in each row, etc.) can be

specified with glPixelStore. So that operations on pixel data can be defined more precisely, pixels

read from application memory are converted into a coherent stream of pixels by an operation

referred to as PIXEL UNPACKING (12). When a pixel rectangle is transferred to OpenGL by a call like

glDrawPixels, this operation applies the current set of pixel unpacking parameters to determine

how the image data should be read and interpreted. As each pixel is read from memory, it is

converted to a PIXEL GROUP that contains either a color, a depth, or a stencil value. If the pixel

group consists of a color, the image data is destined for the color buffer in the frame buffer. If

the pixel group consists of a depth value, the image data is destined for the depth buffer. If the

pixel group consists of a stencil value, the image data is destined for the stencil buffer. Color

values are made up of a red, a green, a blue, and an alpha component (i.e., RGBA) and are

constructed from the input image data according to a set of rules defined by OpenGL. The result

is a stream of RGBA values that are sent to OpenGL for further processing.

1.8.2. Pixel Transfer

After a coherent stream of image pixels is created, pixel rectangles undergo a series of

operations called PIXEL TRANSFER (13). These operations are applied whenever pixel rectangles are

transferred from the application to OpenGL (glDrawPixels, glTexImage, glTexSubImage), from OpenGL

back to the application (glReadPixels), or when they are copied within OpenGL (glCopyPixels,

glCopyTexImage, glCopyTexSubImage).

The behavior of the pixel transfer stage is modified with glPixelTransfer. This command sets state

that controls whether red, green, blue, alpha, and depth values are scaled and biased. It can

also set state that determines whether incoming color or stencil values are mapped to different

color or stencil values through the use of a lookup table. The lookup tables used for these

operations are specified with the glPixelMap command.

Some additional operations that occur at this stage are part of the OpenGL IMAGING SUBSET, which

is an optional part of OpenGL. Hardware vendors that find it important to support advanced

imaging capabilities will support the imaging subset in their OpenGL implementations, and other

vendors will not support it. To determine whether the imaging subset is supported, applications

need to call glGetString with the symbolic constant GL_EXTENSIONS. This returns a list of

extensions supported by the implementation; the application should check for the presence of

the string "ARB_imaging" within the returned extension string.

The pixel transfer operations that are defined to be part of the imaging subset are convolution,

color matrix, histogram, min/max, and additional color lookup tables. Together, they provide

powerful image processing and color correction operations on image data as it is being

transferred to, from, or within OpenGL.

1.8.3. Rasterization and Back-End Processing

Following the pixel transfer stage, fragments are generated through rasterization of pixel

rectangles in much the same way as they are generated from 3D geometry (14). This process,

along with the current OpenGL state, determines where the image will be drawn in the frame

buffer. Rasterization takes into account the current RASTER POSITION, which can be set with

glRasterPos or glWindowPos, and the current zoom factor, which can be set with glPixelZoom and

which causes an image to be magnified or reduced in size as it is drawn.

After fragments have been generated from pixel rectangles, they undergo the same set of

fragment processing operations as geometric primitives (6) and then go on to the remainder of

the OpenGL pipeline in exactly the same manner as geometric primitives, all the way until

pixels are deposited in the frame buffer (8, 9, 10).

Pixel values provided through a call to glTexImage or glTexSubImage do not go through rasterization

or the subsequent fragment processing but directly update the appropriate portion of texture

memory (15).

1.8.4. Read Control

Pixel rectangles are read from the frame buffer and returned to application memory with

glReadPixels. They can also be read from the frame buffer and written to another portion of the

frame buffer with glCopyPixels, or they can be read from the frame buffer and written into texture

memory with glCopyTexImage or glCopyTexSubImage. In all of these cases, the portion of the frame

buffer that is to be read is controlled by the READ CONTROL stage of OpenGL and set with the

glReadBuffer command (16).

The values read from the frame buffer are sent through the pixel transfer stage (13) in which

various image processing operations can be performed. For copy operations, the resulting pixels

are sent to texture memory or back into the frame buffer, depending on the command that

initiated the transfer. For read operations, the pixels are formatted for storage in application

memory under the control of the PIXEL PACKING stage (17). This stage is the mirror of the pixel

unpacking stage (12), in that parameters that define how the image data is to be stored in

memory (length of each pixel row, number of rows to skip before the first one, number of pixels

to skip before the first one in each row, etc.) can be specified with glPixelStore. Thus, application

developers enjoy a lot of flexibility in determining how the image data is returned from OpenGL

into application memory.

这篇关于1.8. 绘制图片 Drawing Images的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/584977

相关文章

QT6中绘制UI的两种方法详解与示例代码

《QT6中绘制UI的两种方法详解与示例代码》Qt6提供了两种主要的UI绘制技术:​​QML(QtMeta-ObjectLanguage)​​和​​C++Widgets​​,这两种技术各有优势,适用于不... 目录一、QML 技术详解1.1 QML 简介1.2 QML 的核心概念1.3 QML 示例:简单按钮

Java实现图片淡入淡出效果

《Java实现图片淡入淡出效果》在现代图形用户界面和游戏开发中,**图片淡入淡出(FadeIn/Out)**是一种常见且实用的视觉过渡效果,它可以用于启动画面、场景切换、轮播图、提示框弹出等场景,通过... 目录1. 项目背景详细介绍2. 项目需求详细介绍2.1 功能需求2.2 非功能需求3. 相关技术详细

Java如何根据文件名前缀自动分组图片文件

《Java如何根据文件名前缀自动分组图片文件》一大堆文件(比如图片)堆在一个目录下,它们的命名规则遵循一定的格式,混在一起很难管理,所以本文小编就和大家介绍一下如何使用Java根据文件名前缀自动分组图... 目录需求背景分析思路实现代码输出结果知识扩展需求一大堆文件(比如图片)堆在一个目录下,它们的命名规

将图片导入Python的turtle库的详细过程

《将图片导入Python的turtle库的详细过程》在Python编程的世界里,turtle库以其简单易用、图形化交互的特点,深受初学者喜爱,随着项目的复杂度增加,仅仅依靠线条和颜色来绘制图形可能已经... 目录开篇引言正文剖析1. 理解基础:Turtle库的工作原理2. 图片格式与支持3. 实现步骤详解第

在React聊天应用中实现图片上传功能

《在React聊天应用中实现图片上传功能》在现代聊天应用中,除了文字和表情,图片分享也是一个重要的功能,本文将详细介绍如何在基于React的聊天应用中实现图片上传和预览功能,感兴趣的小伙伴跟着小编一起... 目录技术栈实现步骤1. 消息组件改造2. 图片预览组件3. 聊天输入组件改造功能特点使用说明注意事项

Python使用Matplotlib绘制3D曲面图详解

《Python使用Matplotlib绘制3D曲面图详解》:本文主要介绍Python使用Matplotlib绘制3D曲面图,在Python中,使用Matplotlib库绘制3D曲面图可以通过mpl... 目录准备工作绘制简单的 3D 曲面图绘制 3D 曲面图添加线框和透明度控制图形视角Matplotlib

Android使用ImageView.ScaleType实现图片的缩放与裁剪功能

《Android使用ImageView.ScaleType实现图片的缩放与裁剪功能》ImageView是最常用的控件之一,它用于展示各种类型的图片,为了能够根据需求调整图片的显示效果,Android提... 目录什么是 ImageView.ScaleType?FIT_XYFIT_STARTFIT_CENTE

关于MongoDB图片URL存储异常问题以及解决

《关于MongoDB图片URL存储异常问题以及解决》:本文主要介绍关于MongoDB图片URL存储异常问题以及解决方案,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐... 目录MongoDB图片URL存储异常问题项目场景问题描述原因分析解决方案预防措施js总结MongoDB图

python实现svg图片转换为png和gif

《python实现svg图片转换为png和gif》这篇文章主要为大家详细介绍了python如何实现将svg图片格式转换为png和gif,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录python实现svg图片转换为png和gifpython实现图片格式之间的相互转换延展:基于Py

使用Python从PPT文档中提取图片和图片信息(如坐标、宽度和高度等)

《使用Python从PPT文档中提取图片和图片信息(如坐标、宽度和高度等)》PPT是一种高效的信息展示工具,广泛应用于教育、商务和设计等多个领域,PPT文档中常常包含丰富的图片内容,这些图片不仅提升了... 目录一、引言二、环境与工具三、python 提取PPT背景图片3.1 提取幻灯片背景图片3.2 提取