diff options
author | Brian Paul <[email protected]> | 2000-03-21 00:48:53 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2000-03-21 00:48:53 +0000 |
commit | ae40595b6943d41dfad0e9b500d5db70b2ad8c6e (patch) | |
tree | 0f28842927e44dbcd7c3097abb5db607ab4e18a8 /src/mesa | |
parent | 8a4014c6fbc1ee3ac487ab10e3b073c62f62b85e (diff) |
added _mesa_image_row_stride()
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/main/image.c | 40 | ||||
-rw-r--r-- | src/mesa/main/image.h | 7 |
2 files changed, 45 insertions, 2 deletions
diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index b1f64fb3fdf..9869d8cf949 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -1,4 +1,4 @@ -/* $Id: image.c,v 1.20 2000/03/19 01:10:12 brianp Exp $ */ +/* $Id: image.c,v 1.21 2000/03/21 00:48:53 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -490,6 +490,44 @@ GLvoid *gl_pixel_addr_in_image( const struct gl_pixelstore_attrib *packing, /* + * Compute the stride between image rows (in bytes) for the given + * pixel packing parameters and image width, format and type. + */ +GLint +_mesa_image_row_stride( const struct gl_pixelstore_attrib *packing, + GLint width, GLenum format, GLenum type ) +{ + ASSERT(packing); + if (type == GL_BITMAP) { + /* BITMAP data */ + if (packing->RowLength == 0) { + GLint bytes = (width + 7) / 8; + return bytes; + } + else { + GLint bytes = (packing->RowLength + 7) / 8; + return bytes; + } + } + else { + /* Non-BITMAP data */ + const GLint bytesPerPixel = gl_bytes_per_pixel(format, type); + if (bytesPerPixel <= 0) + return -1; /* error */ + if (packing->RowLength == 0) { + GLint bytes = bytesPerPixel * width; + return bytes; + } + else { + GLint bytes = bytesPerPixel * packing->RowLength; + return bytes; + } + } +} + + + +/* * Unpack a 32x32 pixel polygon stipple from user memory using the * current pixel unpack settings. */ diff --git a/src/mesa/main/image.h b/src/mesa/main/image.h index 252363c8da2..758213995df 100644 --- a/src/mesa/main/image.h +++ b/src/mesa/main/image.h @@ -1,4 +1,4 @@ -/* $Id: image.h,v 1.4 2000/03/13 18:31:51 brianp Exp $ */ +/* $Id: image.h,v 1.5 2000/03/21 00:48:53 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -61,6 +61,11 @@ gl_pixel_addr_in_image( const struct gl_pixelstore_attrib *packing, GLint img, GLint row, GLint column ); +extern GLint +_mesa_image_row_stride( const struct gl_pixelstore_attrib *packing, + GLint width, GLenum format, GLenum type ); + + extern void _mesa_unpack_polygon_stipple( const GLubyte *pattern, GLuint dest[32], const struct gl_pixelstore_attrib *unpacking ); |