A3DGraphPictureData
Fields
|
|
Detailed Description
-
struct A3DGraphPictureData
A description of a two-dimensional picture.
A picture is a set of color information organised according to a specific memory layout known as format. HOOPS supports various layouts such as RGB or grayscale.
- Version
2.0
Pictures are mainly used within textures descriptions. To known how to read or define texture information within Exchange, see
A3DGraphTextureDefinitionData.The pixel array is describes row-major, where the origin is at the topleft corner of the image.
- Encoding
Raw picture data are written into
m_pucBinaryData. Description for the actual content depends on the picture format selected intom_eFormat. When dimensions of the picture is not encoded within the data, image width and height are written intom_uiPixelWidthandm_uiPixelHeightrespectively, in pixels.- Raw color data
m_pucBinaryDatacan hold a raw pixel array where each byte describes a component for one pixel. According to the value form_eFormat:kA3DPictureBitmapGreyByte: Each pixel is encoded within one byte with a value of the range [0 ; 255]. This format is generally used for grayscale images.kA3DPictureBitmapGreyaByte: Same askA3DPictureBitmapGreyBytebut each value is followed by a second pixel information, generally used for alpha (transparency) channel.kA3DPictureBitmapRgbByte: Each pixel is encoded within a triplet of bytes which descriped the red, green and blue components of the pixel in memory order.kA3DPictureBitmapRgbaByte: Same askA3DPictureBitmapRgbBytebut a fourth byte is added at the end of each triplet, generally for alpha (transparency) information.
The following code describes an RGB 255x100 image with a color fading from red to green:
The following function is an example on how to use [OpenGL 4A3DGraphPictureData picture; A3D_INITIALIZE_DATA(A3DGraphPictureData, picture); picture.m_eFormat = kA3DPictureBitmapRgbByte; picture.m_uiPixelWidth = 255; picture.m_uiPixelHeight = 100; picture.m_uiSize = picture.m_uiPixelWidth * picture.m_uiPixelHeight * 3; picture.m_pucBinaryData = malloc(picture.m_uiSize); for (A3DUns32 row = 0 ; row < picture.m_uiPixelHeight ; ++row) { for (A3DUns32 column = 0 ; column < picture.m_uiPixelHeight ; ++column) { A3DUns32 red_i = (picture.m_uiPixelWidth * row + column) * 3; A3DUns32 green_i = red_i + 1; A3DUns32 blue_i = green_i + 1; picture.m_pucBinaryData[red_i] = 255 - row; picture.m_pucBinaryData[green_i] = row; picture.m_pucBinaryData[blue] = 0; } }
glTexImage2D] with HOOPS picture data:A3DStatus picture_data_to_gl_texture(const A3DGraphPictureData* picture) { assert(picture); GLenum target = GL_TEXTURE_2D; GLenum level = 0; GLsizei width = picture->m_uiPixelWidth; GLsizei height = picture->m_uiPixelHeight; GLint border = 0; GLenum type = GL_UNSIGNED_BYTE; GLint internalformat; GLenum format; switch(picture->m_eFormat) { case kA3DPictureBitmapGreyByte: internalformat = GL_RED; format = GL_RED_INTEGER; break; case kA3DPictureBitmapGreyaByte: internalformat = GL_RG; format = GL_RG_INTEGER; break; case kA3DPictureBitmapRgbByte: internalformat = GL_RGB; format = GL_RGB_INTEGER; break; case kA3DPictureBitmapRgbaByte: internalformat = GL_RGBA; format = GL_RGBA_INTEGER; break; default: return A3D_ERROR; } glTexImage2D(target, level, internalformat, width, height, border, format, type, picture->m_pucBinaryData ); return A3D_SUCCESS; }
See also
See also
See also
- Complex format
m_pucBinaryDatacan contains encoded BMP, PNG or JPEG data accoring to the value ofm_eFormat. In those cases, the dimension of the picture is part of the data. Thusm_uiPixelWidthandm_uiPixelHeightare set to 0.- Memory management
The content of
m_pucBinaryDatais allocated from the heap. When creating a picture instance, you are responsible for the management of its memory. When inserting a newA3DGraphPictureDatainstance into the global state using#A3DGlobalInsertGraphPicture, the content ofm_pucBinaryDatais cloned for internal use.
Public Members
-
A3DEPictureDataFormat m_eFormat
Image format specifier.