/*
-** License Applicability. Except to the extent portions of this file are
-** made subject to an alternative license as permitted in the SGI Free
-** Software License B, Version 1.1 (the "License"), the contents of this
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** Original Code. The Original Code is: OpenGL Sample Implementation,
-** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
-** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-**
-*/
+ * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
+ * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice including the dates of first publication and
+ * either this permission notice or a reference to
+ * http://oss.sgi.com/projects/FreeB/
+ * shall be included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of Silicon Graphics, Inc.
+ * shall not be used in advertising or otherwise to promote the sale, use or
+ * other dealings in this Software without prior written authorization from
+ * Silicon Graphics, Inc.
+ */
#include "gluos.h"
#include <assert.h>
#include <string.h>
#include <limits.h> /* UINT_MAX */
#include <math.h>
-#include "gluint.h"
typedef union {
unsigned char ub[4];
{
int i, j, k;
int newwidth, newheight;
+ int padBytes;
GLubyte *s;
const char *t;
newwidth = width / 2;
newheight = height / 2;
+ padBytes = ysize - (width*group_size);
s = dataout;
t = (const char *)datain;
}
t += group_size;
}
+ t += padBytes;
t += ysize;
}
}
{
int i, j, k;
int newwidth, newheight;
+ int padBytes;
GLbyte *s;
const char *t;
newwidth = width / 2;
newheight = height / 2;
+ padBytes = ysize - (width*group_size);
s = dataout;
t = (const char *)datain;
}
t += group_size;
}
+ t += padBytes;
t += ysize;
}
}
{
int i, j, k;
int newwidth, newheight;
+ int padBytes;
GLushort *s;
const char *t;
newwidth = width / 2;
newheight = height / 2;
+ padBytes = ysize - (width*group_size);
s = dataout;
t = (const char *)datain;
}
t += group_size;
}
+ t += padBytes;
t += ysize;
}
else
}
t += group_size;
}
+ t += padBytes;
t += ysize;
}
}
{
int i, j, k;
int newwidth, newheight;
+ int padBytes;
GLshort *s;
const char *t;
newwidth = width / 2;
newheight = height / 2;
+ padBytes = ysize - (width*group_size);
s = dataout;
t = (const char *)datain;
}
t += group_size;
}
+ t += padBytes;
t += ysize;
}
else
}
t += group_size;
}
+ t += padBytes;
t += ysize;
}
}
{
int i, j, k;
int newwidth, newheight;
+ int padBytes;
GLuint *s;
const char *t;
newwidth = width / 2;
newheight = height / 2;
+ padBytes = ysize - (width*group_size);
s = dataout;
t = (const char *)datain;
}
t += group_size;
}
+ t += padBytes;
t += ysize;
}
else
}
t += group_size;
}
+ t += padBytes;
t += ysize;
}
}
{
int i, j, k;
int newwidth, newheight;
+ int padBytes;
GLint *s;
const char *t;
newwidth = width / 2;
newheight = height / 2;
+ padBytes = ysize - (width*group_size);
s = dataout;
t = (const char *)datain;
}
t += group_size;
}
+ t += padBytes;
t += ysize;
}
else
}
t += group_size;
}
+ t += padBytes;
t += ysize;
}
}
{
int i, j, k;
int newwidth, newheight;
+ int padBytes;
GLfloat *s;
const char *t;
newwidth = width / 2;
newheight = height / 2;
+ padBytes = ysize - (width*group_size);
s = dataout;
t = (const char *)datain;
}
t += group_size;
}
+ t += padBytes;
t += ysize;
}
else
for (i = 0; i < newheight; i++) {
for (j = 0; j < newwidth; j++) {
for (k = 0; k < components; k++) {
- GLuint b;
- b = __GLU_SWAP_4_BYTES(t);
- s[0] = *(GLfloat*)&b;
- b = __GLU_SWAP_4_BYTES(t+group_size);
- s[0] += *(GLfloat*)&b;
- b = __GLU_SWAP_4_BYTES(t+ysize);
- s[0] += *(GLfloat*)&b;
- b = __GLU_SWAP_4_BYTES(t+ysize+group_size);
- s[0] += *(GLfloat*)&b;
+ union { GLuint b; GLfloat f; } swapbuf;
+ swapbuf.b = __GLU_SWAP_4_BYTES(t);
+ s[0] = swapbuf.f;
+ swapbuf.b = __GLU_SWAP_4_BYTES(t+group_size);
+ s[0] += swapbuf.f;
+ swapbuf.b = __GLU_SWAP_4_BYTES(t+ysize);
+ s[0] += swapbuf.f;
+ swapbuf.b = __GLU_SWAP_4_BYTES(t+ysize+group_size);
+ s[0] += swapbuf.f;
s[0] /= 4;
s++; t += element_size;
}
t += group_size;
}
+ t += padBytes;
t += ysize;
}
}
highy_float = convy_float;
for (i = 0; i < heightout; i++) {
+ /* Clamp here to be sure we don't read beyond input buffer. */
+ if (highy_int >= heightin)
+ highy_int = heightin - 1;
lowx_int = 0;
lowx_float = 0;
highx_int = convx_int;
totals[k] += (GLubyte)(*(temp_index)) * percent;
}
- /* calculate the value for pixels in the last row */
+ /* calculate the value for pixels in the last row */
y_percent = highy_float;
percent = y_percent * (1-lowx_float);
temp = (const char *)datain + xindex + highy_int * ysize;
highy_float = convy_float;
for (i = 0; i < heightout; i++) {
+ /* Clamp here to be sure we don't read beyond input buffer. */
+ if (highy_int >= heightin)
+ highy_int = heightin - 1;
lowx_int = 0;
lowx_float = 0;
highx_int = convx_int;
highy_float = convy_float;
for (i = 0; i < heightout; i++) {
+ /* Clamp here to be sure we don't read beyond input buffer. */
+ if (highy_int >= heightin)
+ highy_int = heightin - 1;
lowx_int = 0;
lowx_float = 0;
highx_int = convx_int;
highy_float = convy_float;
for (i = 0; i < heightout; i++) {
+ /* Clamp here to be sure we don't read beyond input buffer. */
+ if (highy_int >= heightin)
+ highy_int = heightin - 1;
lowx_int = 0;
lowx_float = 0;
highx_int = convx_int;
highy_float = convy_float;
for (i = 0; i < heightout; i++) {
+ /* Clamp here to be sure we don't read beyond input buffer. */
+ if (highy_int >= heightin)
+ highy_int = heightin - 1;
lowx_int = 0;
lowx_float = 0;
highx_int = convx_int;
highy_float = convy_float;
for (i = 0; i < heightout; i++) {
+ /* Clamp here to be sure we don't read beyond input buffer. */
+ if (highy_int >= heightin)
+ highy_int = heightin - 1;
lowx_int = 0;
lowx_float = 0;
highx_int = convx_int;
int l, m;
const char *left, *right;
- GLuint swapbuf; /* unsigned buffer */
+ union { GLuint b; GLfloat f; } swapbuf;
if (widthin == widthout*2 && heightin == heightout*2) {
halveImage_float(components, widthin, heightin,
highy_float = convy_float;
for (i = 0; i < heightout; i++) {
+ /* Clamp here to be sure we don't read beyond input buffer. */
+ if (highy_int >= heightin)
+ highy_int = heightin - 1;
lowx_int = 0;
lowx_float = 0;
highx_int = convx_int;
for (k = 0, temp_index = temp; k < components;
k++, temp_index += element_size) {
if (myswap_bytes) {
- swapbuf = __GLU_SWAP_4_BYTES(temp_index);
- totals[k] += *(const GLfloat*)&swapbuf * percent;
+ swapbuf.b = __GLU_SWAP_4_BYTES(temp_index);
+ totals[k] += swapbuf.f * percent;
} else {
totals[k] += *(const GLfloat*)temp_index * percent;
}
for (k = 0, temp_index = temp; k < components;
k++, temp_index += element_size) {
if (myswap_bytes) {
- swapbuf = __GLU_SWAP_4_BYTES(temp_index);
- totals[k] += *(const GLfloat*)&swapbuf * y_percent;
+ swapbuf.b = __GLU_SWAP_4_BYTES(temp_index);
+ totals[k] += swapbuf.f * y_percent;
} else {
totals[k] += *(const GLfloat*)temp_index * y_percent;
}
for (k = 0, temp_index = temp; k < components;
k++, temp_index += element_size) {
if (myswap_bytes) {
- swapbuf = __GLU_SWAP_4_BYTES(temp_index);
- totals[k] += *(const GLfloat*)&swapbuf * percent;
+ swapbuf.b = __GLU_SWAP_4_BYTES(temp_index);
+ totals[k] += swapbuf.f * percent;
} else {
totals[k] += *(const GLfloat*)temp_index * percent;
}
for (k = 0, temp_index = temp; k < components;
k++, temp_index += element_size) {
if (myswap_bytes) {
- swapbuf = __GLU_SWAP_4_BYTES(temp_index);
- totals[k] += *(const GLfloat*)&swapbuf * percent;
+ swapbuf.b = __GLU_SWAP_4_BYTES(temp_index);
+ totals[k] += swapbuf.f * percent;
} else {
totals[k] += *(const GLfloat*)temp_index * percent;
}
for (k = 0, temp_index = temp; k < components;
k++, temp_index += element_size) {
if (myswap_bytes) {
- swapbuf = __GLU_SWAP_4_BYTES(temp_index);
- totals[k] += *(const GLfloat*)&swapbuf * y_percent;
+ swapbuf.b = __GLU_SWAP_4_BYTES(temp_index);
+ totals[k] += swapbuf.f * y_percent;
} else {
totals[k] += *(const GLfloat*)temp_index * y_percent;
}
for (k = 0, temp_index = temp; k < components;
k++, temp_index += element_size) {
if (myswap_bytes) {
- swapbuf = __GLU_SWAP_4_BYTES(temp_index);
- totals[k] += *(const GLfloat*)&swapbuf * percent;
+ swapbuf.b = __GLU_SWAP_4_BYTES(temp_index);
+ totals[k] += swapbuf.f * percent;
} else {
totals[k] += *(const GLfloat*)temp_index * percent;
}
for (k = 0; k < components;
k++, left += element_size, right += element_size) {
if (myswap_bytes) {
- swapbuf = __GLU_SWAP_4_BYTES(left);
- totals[k] += *(const GLfloat*)&swapbuf * (1-lowx_float);
- swapbuf = __GLU_SWAP_4_BYTES(right);
- totals[k] += *(const GLfloat*)&swapbuf * highx_float;
+ swapbuf.b = __GLU_SWAP_4_BYTES(left);
+ totals[k] += swapbuf.f * (1-lowx_float);
+ swapbuf.b = __GLU_SWAP_4_BYTES(right);
+ totals[k] += swapbuf.f * highx_float;
} else {
totals[k] += *(const GLfloat*)left * (1-lowx_float)
+ *(const GLfloat*)right * highx_float;
for (k = 0, temp_index = temp; k < components;
k++, temp_index += element_size) {
if (myswap_bytes) {
- swapbuf = __GLU_SWAP_4_BYTES(temp_index);
- totals[k] += *(const GLfloat*)&swapbuf * percent;
+ swapbuf.b = __GLU_SWAP_4_BYTES(temp_index);
+ totals[k] += swapbuf.f * percent;
} else {
totals[k] += *(const GLfloat*)temp_index * percent;
}
for (k = 0, temp_index = temp; k < components;
k++, temp_index += element_size) {
if (myswap_bytes) {
- swapbuf = __GLU_SWAP_4_BYTES(temp_index);
- totals[k] += *(const GLfloat*)&swapbuf * x_percent;
+ swapbuf.b = __GLU_SWAP_4_BYTES(temp_index);
+ totals[k] += swapbuf.f * x_percent;
} else {
totals[k] += *(const GLfloat*)temp_index * x_percent;
}
for (k = 0, temp_index = temp; k < components;
k++, temp_index += element_size) {
if (myswap_bytes) {
- swapbuf = __GLU_SWAP_4_BYTES(temp_index);
- totals[k] += *(const GLfloat*)&swapbuf * percent;
+ swapbuf.b = __GLU_SWAP_4_BYTES(temp_index);
+ totals[k] += swapbuf.f * percent;
} else {
totals[k] += *(const GLfloat*)temp_index * percent;
}
for (k = 0, temp_index = temp; k < components;
k++, temp_index += element_size) {
if (myswap_bytes) {
- swapbuf = __GLU_SWAP_4_BYTES(temp_index);
- totals[k] += *(const GLfloat*)&swapbuf * percent;
+ swapbuf.b = __GLU_SWAP_4_BYTES(temp_index);
+ totals[k] += swapbuf.f * percent;
} else {
totals[k] += *(const GLfloat*)temp_index * percent;
}
for (k = 0, temp_index = temp; k < components;
k++, temp_index += element_size) {
if (myswap_bytes) {
- swapbuf = __GLU_SWAP_4_BYTES(temp_index);
- totals[k] += *(const GLfloat*)&swapbuf * y_percent;
+ swapbuf.b = __GLU_SWAP_4_BYTES(temp_index);
+ totals[k] += swapbuf.f * y_percent;
} else {
totals[k] += *(const GLfloat*)temp_index * y_percent;
}
for (k = 0, temp_index = temp; k < components;
k++, temp_index += element_size) {
if (myswap_bytes) {
- swapbuf = __GLU_SWAP_4_BYTES(temp_index);
- totals[k] += *(const GLfloat*)&swapbuf * percent;
+ swapbuf.b = __GLU_SWAP_4_BYTES(temp_index);
+ totals[k] += swapbuf.f * percent;
} else {
totals[k] += *(const GLfloat*)temp_index * percent;
}
for (k = 0, temp_index = temp; k < components;
k++, temp_index += element_size) {
if (myswap_bytes) {
- swapbuf = __GLU_SWAP_4_BYTES(temp_index);
- totals[k] += *(const GLfloat*)&swapbuf * percent;
+ swapbuf.b = __GLU_SWAP_4_BYTES(temp_index);
+ totals[k] += swapbuf.f * percent;
} else {
totals[k] += *(const GLfloat*)temp_index * percent;
}
for (k = 0, temp_index = temp; k < components;
k++, temp_index += element_size) {
if (myswap_bytes) {
- swapbuf = __GLU_SWAP_4_BYTES(temp_index);
- totals[k] += *(const GLfloat*)&swapbuf;
+ swapbuf.b = __GLU_SWAP_4_BYTES(temp_index);
+ totals[k] += swapbuf.f;
} else {
totals[k] += *(const GLfloat*)temp_index;
}
afterImage =
malloc(image_size(widthout, heightout, format, GL_UNSIGNED_SHORT));
if (beforeImage == NULL || afterImage == NULL) {
+ free(beforeImage);
+ free(afterImage);
return GLU_OUT_OF_MEMORY;
}
glPixelStorei(GL_UNPACK_SKIP_PIXELS,psm.unpack_skip_pixels);
glPixelStorei(GL_UNPACK_ROW_LENGTH, psm.unpack_row_length);
glPixelStorei(GL_UNPACK_SWAP_BYTES, psm.unpack_swap_bytes);
+ free(newImage);
return GLU_OUT_OF_MEMORY;
}
}
glPixelStorei(GL_UNPACK_SKIP_PIXELS,psm.unpack_skip_pixels);
glPixelStorei(GL_UNPACK_ROW_LENGTH, psm.unpack_row_length);
glPixelStorei(GL_UNPACK_SWAP_BYTES, psm.unpack_swap_bytes);
+ free(newImage);
return GLU_OUT_OF_MEMORY;
}
}
if (width == newwidth && height == newheight) {
/* Use usersImage for level userLevel */
if (baseLevel <= level && level <= maxLevel) {
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, psm.unpack_row_length);
glTexImage2D(target, level, internalFormat, width,
height, 0, format, type,
usersImage);
}
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
if(levels == 0) { /* we're done. clean up and return */
glPixelStorei(GL_UNPACK_ALIGNMENT, psm.unpack_alignment);
glPixelStorei(GL_UNPACK_SKIP_ROWS, psm.unpack_skip_rows);
glPixelStorei(GL_UNPACK_SKIP_PIXELS, psm.unpack_skip_pixels);
glPixelStorei(GL_UNPACK_ROW_LENGTH, psm.unpack_row_length);
glPixelStorei(GL_UNPACK_SWAP_BYTES, psm.unpack_swap_bytes);
+ free(srcImage);
return GLU_OUT_OF_MEMORY;
}
/* level userLevel+1 is in srcImage; level userLevel already saved */
glPixelStorei(GL_UNPACK_SKIP_PIXELS, psm.unpack_skip_pixels);
glPixelStorei(GL_UNPACK_ROW_LENGTH, psm.unpack_row_length);
glPixelStorei(GL_UNPACK_SWAP_BYTES, psm.unpack_swap_bytes);
+ free(srcImage);
return GLU_OUT_OF_MEMORY;
}
}
static void extract565(int isSwap,
const void *packedPixel, GLfloat extractComponents[])
{
- GLushort ushort= *(const GLushort *)packedPixel;
+ GLushort ushort;
if (isSwap) {
ushort= __GLU_SWAP_2_BYTES(packedPixel);
static void extract565rev(int isSwap,
const void *packedPixel, GLfloat extractComponents[])
{
- GLushort ushort= *(const GLushort *)packedPixel;
+ GLushort ushort;
if (isSwap) {
ushort= __GLU_SWAP_2_BYTES(packedPixel);
* Contributed by Gerk Huisma <gerk@five-d.demon.nl>.
*/
-typedef GLAPI void (GLAPIENTRY *TexImage3Dproc)( GLenum target, GLint level,
+typedef void (GLAPIENTRY *TexImage3Dproc)( GLenum target, GLint level,
GLenum internalFormat,
GLsizei width, GLsizei height,
GLsizei depth, GLint border,
GLenum format, GLenum type,
const GLvoid *pixels );
-static TexImage3Dproc pTexImage3D;
+static TexImage3Dproc pTexImage3D = 0;
-#ifndef WIN32
+#if !defined(_WIN32) && !defined(__WIN32__)
# include <dlfcn.h>
# include <sys/types.h>
#else
const GLvoid *pixels )
{
if (!pTexImage3D) {
-#ifdef WIN32
+#if defined(_WIN32) || defined(__WIN32__)
pTexImage3D = (TexImage3Dproc) wglGetProcAddress("glTexImage3D");
if (!pTexImage3D)
pTexImage3D = (TexImage3Dproc) wglGetProcAddress("glTexImage3DEXT");
#else
void *libHandle = dlopen("libgl.so", RTLD_LAZY);
- pTexImage3D = TexImage3Dproc) dlsym(libHandle, "glTexImage3D" );
+ pTexImage3D = (TexImage3Dproc) dlsym(libHandle, "glTexImage3D" );
if (!pTexImage3D)
pTexImage3D = (TexImage3Dproc) dlsym(libHandle,"glTexImage3DEXT");
dlclose(libHandle);
afterImage = malloc(imageSize3D(widthOut, heightOut, depthOut, format,
GL_UNSIGNED_SHORT));
if (beforeImage == NULL || afterImage == NULL) {
+ free(beforeImage);
+ free(afterImage);
return GLU_OUT_OF_MEMORY;
}
retrieveStoreModes3D(&psm);
GLint depthAtLevelOne= (depthPowerOf2 > 1) ?
depthPowerOf2 >> 1 :
depthPowerOf2;
- GLenum proxyTarget;
+ GLenum proxyTarget = GL_PROXY_TEXTURE_3D;
assert(widthAtLevelOne > 0);
assert(heightAtLevelOne > 0);
assert(depthAtLevelOne > 0);
/* does width x height x depth at level 1 & all their mipmaps fit? */
- if (target == GL_TEXTURE_3D || target == GL_PROXY_TEXTURE_3D) {
- proxyTarget = GL_PROXY_TEXTURE_3D;
- gluTexImage3D(proxyTarget, 1, /* must be non-zero */
- internalFormat,
- widthAtLevelOne,heightAtLevelOne,depthAtLevelOne,
- 0,format,type,NULL);
- }
+ assert(target == GL_TEXTURE_3D || target == GL_PROXY_TEXTURE_3D);
+ gluTexImage3D(proxyTarget, 1, /* must be non-zero */
+ internalFormat,
+ widthAtLevelOne,heightAtLevelOne,depthAtLevelOne,
+ 0,format,type,NULL);
glGetTexLevelParameteriv(proxyTarget, 1,GL_TEXTURE_WIDTH,&proxyWidth);
/* does it fit??? */
if (proxyWidth == 0) { /* nope, so try again with these sizes */
glPixelStorei(GL_UNPACK_SWAP_BYTES, psm.unpack_swap_bytes);
glPixelStorei(GL_UNPACK_SKIP_IMAGES, psm.unpack_skip_images);
glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, psm.unpack_image_height);
+ free(srcImage);
return GLU_OUT_OF_MEMORY;
}
/* level userLevel+1 is in srcImage; level userLevel already saved */
glPixelStorei(GL_UNPACK_SWAP_BYTES, psm.unpack_swap_bytes);
glPixelStorei(GL_UNPACK_SKIP_IMAGES, psm.unpack_skip_images);
glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, psm.unpack_image_height);
+ free(srcImage);
return GLU_OUT_OF_MEMORY;
}
}
int halfHeight= height / 2;
int halfDepth= depth / 2;
const char *src= (const char *)dataIn;
- int padBytes= rowSizeInBytes - (width * groupSizeInBytes);
+ int rowPadBytes= rowSizeInBytes - (width * groupSizeInBytes);
+ int imagePadBytes= imageSizeInBytes - (width*height*groupSizeInBytes);
int outIndex= 0;
assert((width == 1 || height == 1) && depth >= 2);
/* skip over to next horizontal square of 4 */
src+= groupSizeInBytes;
} /* for jj */
- src+= padBytes;
+ src+= rowPadBytes;
src+= rowSizeInBytes;
} /* for ii */
src+= elementSizeInBytes;
} /* for cc */
- src+= padBytes;
+ src+= rowPadBytes;
/* skip over to next vertical square of 4 */
src+= rowSizeInBytes;
} /* for jj */
+ src+= imagePadBytes;
src+= imageSizeInBytes;
} /* for ii */
int halfHeight= height / 2;
int halfDepth= depth / 2;
const char *src= (const char *) dataIn;
- int padBytes= rowSizeInBytes - (width*groupSizeInBytes);
+ int rowPadBytes= rowSizeInBytes - (width*groupSizeInBytes);
+ int imagePadBytes= imageSizeInBytes - (width*height*groupSizeInBytes);
int outIndex= 0;
for (dd= 0; dd < halfDepth; dd++) {
src+= groupSizeInBytes;
} /* for jj */
/* skip past pad bytes, if any, to get to next row */
- src+= padBytes;
+ src+= rowPadBytes;
/* src is at beginning of a row here, but it's the second row of
* the square block of 4 pixels that we just worked on so we
src+= rowSizeInBytes;
} /* for ii */
+ /* skip past pad bytes, if any, to get to next image */
+ src+= imagePadBytes;
+
src+= imageSizeInBytes;
} /* for dd */