ReactOS  0.4.13-dev-563-g0561610
image.h File Reference
#include "types.h"
Include dependency graph for image.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void gl_flip_bytes (GLubyte *p, GLuint n)
 
void gl_swap2 (GLushort *p, GLuint n)
 
void gl_swap4 (GLuint *p, GLuint n)
 
GLint gl_sizeof_type (GLenum type)
 
GLint gl_components_in_format (GLenum format)
 
GLvoidgl_pixel_addr_in_image (struct gl_pixelstore_attrib *packing, const GLvoid *image, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint row)
 
struct gl_imagegl_unpack_image (GLcontext *ctx, GLint width, GLint height, GLenum srcFormat, GLenum srcType, const GLvoid *pixels)
 
void gl_free_image (struct gl_image *image)
 

Function Documentation

◆ gl_components_in_format()

GLint gl_components_in_format ( GLenum  format)

Definition at line 193 of file image.c.

194 {
195  switch (format) {
196  case GL_COLOR_INDEX:
197  case GL_STENCIL_INDEX:
198  case GL_DEPTH_COMPONENT:
199  case GL_RED:
200  case GL_GREEN:
201  case GL_BLUE:
202  case GL_ALPHA:
203  case GL_LUMINANCE:
204  return 1;
205  case GL_LUMINANCE_ALPHA:
206  return 2;
207  case GL_RGB:
208  case GL_BGR_EXT:
209  return 3;
210  case GL_RGBA:
211  case GL_BGRA_EXT:
212  return 4;
213  default:
214  return -1;
215  }
216 }
#define GL_BGR_EXT
Definition: glext.h:3114
#define GL_RED
Definition: gl.h:480
#define GL_ALPHA
Definition: gl.h:483
#define GL_BGRA_EXT
Definition: glext.h:3115
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define GL_LUMINANCE_ALPHA
Definition: gl.h:485
#define GL_RGB
Definition: gl.h:502
#define GL_STENCIL_INDEX
Definition: gl.h:458
#define GL_BLUE
Definition: gl.h:482
#define GL_LUMINANCE
Definition: gl.h:484
#define GL_DEPTH_COMPONENT
Definition: gl.h:307
#define GL_GREEN
Definition: gl.h:481
#define GL_COLOR_INDEX
Definition: gl.h:479
#define GL_RGBA
Definition: gl.h:503

Referenced by gl_pixel_addr_in_image(), gl_TexSubImage2D(), gl_unpack_image(), and gl_unpack_pixels().

◆ gl_flip_bytes()

void gl_flip_bytes ( GLubyte p,
GLuint  n 
)

Definition at line 105 of file image.c.

106 {
107  register GLuint i, a, b;
108 
109  for (i=0;i<n;i++) {
110  b = (GLuint) p[i];
111  a = ((b & 0x01) << 7) |
112  ((b & 0x02) << 5) |
113  ((b & 0x04) << 3) |
114  ((b & 0x08) << 1) |
115  ((b & 0x10) >> 1) |
116  ((b & 0x20) >> 3) |
117  ((b & 0x40) >> 5) |
118  ((b & 0x80) >> 7);
119  p[i] = (GLubyte) a;
120  }
121 }
unsigned char GLubyte
Definition: gl.h:157
GLdouble n
Definition: glext.h:7729
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define a
Definition: ke_i.h:78
#define b
Definition: ke_i.h:79
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
unsigned int GLuint
Definition: gl.h:159
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by gl_unpack_image(), and gl_unpack_pixels().

◆ gl_free_image()

void gl_free_image ( struct gl_image image)

Definition at line 661 of file image.c.

662 {
663  if (image->Data) {
664  free(image->Data);
665  }
666  free(image);
667 }
#define free
Definition: debug_ros.c:5

Referenced by _mesa_Bitmap(), _mesa_ColorSubTableEXT(), _mesa_ColorTableEXT(), gl_destroy_list(), gl_TexImage1D(), gl_TexImage2D(), gl_TexSubImage1D(), and gl_TexSubImage2D().

◆ gl_pixel_addr_in_image()

GLvoid* gl_pixel_addr_in_image ( struct gl_pixelstore_attrib packing,
const GLvoid image,
GLsizei  width,
GLsizei  height,
GLenum  format,
GLenum  type,
GLint  row 
)

Definition at line 232 of file image.c.

236 {
237  GLint bytes_per_comp; /* bytes per component */
238  GLint comp_per_pixel; /* components per pixel */
239  GLint comps_per_row; /* components per row */
240  GLint pixels_per_row; /* pixels per row */
241  GLint alignment; /* 1, 2 or 4 */
242  GLint skiprows;
243  GLint skippixels;
244  GLubyte *pixel_addr;
245 
246  /* Compute bytes per component */
247  bytes_per_comp = gl_sizeof_type( type );
248  if (bytes_per_comp<0) {
249  return NULL;
250  }
251 
252  /* Compute number of components per pixel */
253  comp_per_pixel = gl_components_in_format( format );
254  if (comp_per_pixel<0) {
255  return NULL;
256  }
257 
258  alignment = packing->Alignment;
259  if (packing->RowLength>0) {
260  pixels_per_row = packing->RowLength;
261  }
262  else {
263  pixels_per_row = width;
264  }
265  skiprows = packing->SkipRows;
266  skippixels = packing->SkipPixels;
267 
268  if (type==GL_BITMAP) {
269  /* BITMAP data */
270  GLint bytes_per_row;
271 
272  bytes_per_row = alignment
273  * CEILING( comp_per_pixel*pixels_per_row, 8*alignment );
274 
275  pixel_addr = (GLubyte *) image
276  + (skiprows + row) * bytes_per_row
277  + (skippixels) / 8;
278  }
279  else {
280  /* Non-BITMAP data */
281 
282  if (bytes_per_comp>=alignment) {
283  comps_per_row = comp_per_pixel * pixels_per_row;
284  }
285  else {
286  GLint bytes_per_row = bytes_per_comp * comp_per_pixel
287  * pixels_per_row;
288 
289  comps_per_row = alignment / bytes_per_comp
290  * CEILING( bytes_per_row, alignment );
291  }
292 
293  /* Copy/unpack pixel data to buffer */
294  pixel_addr = (GLubyte *) image
295  + (skiprows + row) * bytes_per_comp * comps_per_row
296  + (skippixels) * bytes_per_comp * comp_per_pixel;
297  }
298 
299  return (GLvoid *) pixel_addr;
300 }
GLint GLint GLsizei width
Definition: gl.h:1546
#define GL_BITMAP
Definition: gl.h:497
unsigned char GLubyte
Definition: gl.h:157
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define CEILING(A, B)
Definition: macros.h:151
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
smooth NULL
Definition: ftsmooth.c:416
GLint gl_sizeof_type(GLenum type)
Definition: image.c:163
GLint gl_components_in_format(GLenum format)
Definition: image.c:193
int GLint
Definition: gl.h:156
struct png_info_def *typedef unsigned char **typedef struct png_info_def *typedef struct png_info_def *typedef struct png_info_def *typedef unsigned char ** row
Definition: typeof.h:78

Referenced by gl_unpack_image(), and gl_unpack_pixels().

◆ gl_sizeof_type()

GLint gl_sizeof_type ( GLenum  type)

Definition at line 163 of file image.c.

164 {
165  switch (type) {
166  case GL_BITMAP:
167  return 0;
168  case GL_UNSIGNED_BYTE:
169  return sizeof(GLubyte);
170  case GL_BYTE:
171  return sizeof(GLbyte);
172  case GL_UNSIGNED_SHORT:
173  return sizeof(GLushort);
174  case GL_SHORT:
175  return sizeof(GLshort);
176  case GL_UNSIGNED_INT:
177  return sizeof(GLuint);
178  case GL_INT:
179  return sizeof(GLint);
180  case GL_FLOAT:
181  return sizeof(GLfloat);
182  default:
183  return -1;
184  }
185 }
#define GL_INT
Definition: gl.h:181
#define GL_UNSIGNED_SHORT
Definition: gl.h:180
#define GL_BITMAP
Definition: gl.h:497
unsigned char GLubyte
Definition: gl.h:157
#define GL_UNSIGNED_BYTE
Definition: gl.h:178
#define GL_FLOAT
Definition: gl.h:183
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define GL_SHORT
Definition: gl.h:179
#define GL_UNSIGNED_INT
Definition: gl.h:182
signed char GLbyte
Definition: gl.h:154
#define GL_BYTE
Definition: gl.h:177
short GLshort
Definition: gl.h:155
unsigned int GLuint
Definition: gl.h:159
float GLfloat
Definition: gl.h:161
int GLint
Definition: gl.h:156
unsigned short GLushort
Definition: gl.h:158

Referenced by gl_pixel_addr_in_image(), gl_TexSubImage1D(), gl_TexSubImage2D(), gl_unpack_pixels(), gl_unpack_texsubimage(), read_color_pixels(), read_depth_pixels(), read_index_pixels(), and read_stencil_pixels().

◆ gl_swap2()

void gl_swap2 ( GLushort p,
GLuint  n 
)

Definition at line 127 of file image.c.

128 {
129  register GLuint i;
130 
131  for (i=0;i<n;i++) {
132  p[i] = (p[i] >> 8) | ((p[i] << 8) & 0xff00);
133  }
134 }
GLdouble n
Definition: glext.h:7729
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int GLuint
Definition: gl.h:159
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by gl_unpack_pixels(), read_color_pixels(), read_depth_pixels(), read_index_pixels(), and read_stencil_pixels().

◆ gl_swap4()

void gl_swap4 ( GLuint p,
GLuint  n 
)

Definition at line 141 of file image.c.

142 {
143  register GLuint i, a, b;
144 
145  for (i=0;i<n;i++) {
146  b = p[i];
147  a = (b >> 24)
148  | ((b >> 8) & 0xff00)
149  | ((b << 8) & 0xff0000)
150  | ((b << 24) & 0xff000000);
151  p[i] = a;
152  }
153 }
GLdouble n
Definition: glext.h:7729
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define a
Definition: ke_i.h:78
#define b
Definition: ke_i.h:79
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
unsigned int GLuint
Definition: gl.h:159
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by gl_unpack_pixels(), read_color_pixels(), read_depth_pixels(), read_index_pixels(), and read_stencil_pixels().

◆ gl_unpack_image()

struct gl_image* gl_unpack_image ( GLcontext ctx,
GLint  width,
GLint  height,
GLenum  srcFormat,
GLenum  srcType,
const GLvoid pixels 
)

img_pixels= pixels;

Definition at line 314 of file image.c.

318 {
320  GLenum destType;
321 
322  if (srcType==GL_UNSIGNED_BYTE) {
323  destType = GL_UNSIGNED_BYTE;
324  }
325  else if (srcType==GL_BITMAP) {
326  destType = GL_BITMAP;
327  }
328  else {
329  destType = GL_FLOAT;
330  }
331 
332  components = gl_components_in_format( srcFormat );
333 
334  if (components < 0)
335  return NULL;
336 
337  if (srcType==GL_BITMAP || destType==GL_BITMAP) {
338  struct gl_image *image;
339  GLint bytes, i, width_in_bytes;
340  GLubyte *buffer, *dst;
341  assert( srcType==GL_BITMAP );
342  assert( destType==GL_BITMAP );
343 
344  /* Alloc dest storage */
345  if (width > 0 && height > 0)
346  bytes = ((width+7)/8 * height);
347  else
348  bytes = 0;
349  if (bytes>0 && pixels!=NULL) {
350  buffer = (GLubyte *) malloc( bytes );
351  if (!buffer) {
352  return NULL;
353  }
354  /* Copy/unpack pixel data to buffer */
355  width_in_bytes = CEILING( width, 8 );
356  dst = buffer;
357  for (i=0; i<height; i++) {
359  width, height,
360  GL_COLOR_INDEX, srcType,
361  i);
362  if (!src) {
363  free(buffer);
364  return NULL;
365  }
366  MEMCPY( dst, src, width_in_bytes );
367  dst += width_in_bytes;
368  }
369  /* Bit flipping */
370  if (ctx->Unpack.LsbFirst) {
372  }
373  }
374  else {
375  /* a 'null' bitmap */
376  buffer = NULL;
377  }
378 
379  image = (struct gl_image *) malloc( sizeof(struct gl_image) );
380  if (image) {
381  image->Width = width;
382  image->Height = height;
383  image->Components = 0;
384  image->Format = GL_COLOR_INDEX;
385  image->Type = GL_BITMAP;
386  image->Data = buffer;
387  image->RefCount = 0;
388  }
389  else {
390  if (buffer)
391  free( buffer );
392  return NULL;
393  }
394  return image;
395  }
396  else if (srcFormat==GL_DEPTH_COMPONENT) {
397  /* TODO: pack as GLdepth values (GLushort or GLuint) */
398 
399  }
400  else if (srcFormat==GL_STENCIL_INDEX) {
401  /* TODO: pack as GLstencil (GLubyte or GLushort) */
402 
403  }
404  else if (destType==GL_UNSIGNED_BYTE) {
405  struct gl_image *image;
406  GLint width_in_bytes;
407  GLubyte *buffer, *dst;
408  GLint i;
409  assert( srcType==GL_UNSIGNED_BYTE );
410 
411  width_in_bytes = width * components * sizeof(GLubyte);
412  buffer = (GLubyte *) malloc( height * width_in_bytes );
413  if (!buffer) {
414  return NULL;
415  }
416  /* Copy/unpack pixel data to buffer */
417  dst = buffer;
418  for (i=0;i<height;i++) {
420  pixels, width, height, srcFormat, srcType, i);
421  if (!src) {
422  free(buffer);
423  return NULL;
424  }
425  MEMCPY( dst, src, width_in_bytes );
426  dst += width_in_bytes;
427  }
428 
429  if (ctx->Unpack.LsbFirst) {
430  gl_flip_bytes( buffer, height * width_in_bytes );
431  }
432 
433  image = (struct gl_image *) malloc( sizeof(struct gl_image) );
434  if (image) {
435  image->Width = width;
436  image->Height = height;
437  image->Components = components;
438  image->Format = srcFormat;
439  image->Type = GL_UNSIGNED_BYTE;
440  image->Data = buffer;
441  image->RefCount = 0;
442  }
443  else {
444  free( buffer );
445  return NULL;
446  }
447  return image;
448  }
449  else if (destType==GL_FLOAT) {
450  struct gl_image *image;
451  GLfloat *buffer, *dst;
452  GLint elems_per_row;
453  GLint i, j;
455  elems_per_row = width * components;
456  buffer = (GLfloat *) malloc( height * elems_per_row * sizeof(GLfloat));
457  if (!buffer) {
458  return NULL;
459  }
460 
461  normalize = (srcFormat != GL_COLOR_INDEX)
462  && (srcFormat != GL_STENCIL_INDEX);
463 
464  dst = buffer;
466  for (i=0;i<height;i++) {
468  width, height,
469  srcFormat, srcType,
470  i);
471  if (!src) {
472  free(buffer);
473  return NULL;
474  }
475 
476  switch (srcType) {
477  case GL_UNSIGNED_BYTE:
478  if (normalize) {
479  for (j=0;j<elems_per_row;j++) {
480  *dst++ = UBYTE_TO_FLOAT(((GLubyte*)src)[j]);
481  }
482  }
483  else {
484  for (j=0;j<elems_per_row;j++) {
485  *dst++ = (GLfloat) ((GLubyte*)src)[j];
486  }
487  }
488  break;
489  case GL_BYTE:
490  if (normalize) {
491  for (j=0;j<elems_per_row;j++) {
492  *dst++ = BYTE_TO_FLOAT(((GLbyte*)src)[j]);
493  }
494  }
495  else {
496  for (j=0;j<elems_per_row;j++) {
497  *dst++ = (GLfloat) ((GLbyte*)src)[j];
498  }
499  }
500  break;
501  case GL_UNSIGNED_SHORT:
502  if (ctx->Unpack.SwapBytes) {
503  for (j=0;j<elems_per_row;j++) {
504  GLushort value = ((GLushort*)src)[j];
505  value = ((value >> 8) & 0xff) | ((value&0xff) << 8);
506  if (normalize) {
507  *dst++ = USHORT_TO_FLOAT(value);
508  }
509  else {
510  *dst++ = (GLfloat) value;
511  }
512  }
513  }
514  else {
515  if (normalize) {
516  for (j=0;j<elems_per_row;j++) {
517  *dst++ = USHORT_TO_FLOAT(((GLushort*)src)[j]);
518  }
519  }
520  else {
521  for (j=0;j<elems_per_row;j++) {
522  *dst++ = (GLfloat) ((GLushort*)src)[j];
523  }
524  }
525  }
526  break;
527  case GL_SHORT:
528  if (ctx->Unpack.SwapBytes) {
529  for (j=0;j<elems_per_row;j++) {
530  GLshort value = ((GLshort*)src)[j];
531  value = ((value >> 8) & 0xff) | ((value&0xff) << 8);
532  if (normalize) {
533  *dst++ = SHORT_TO_FLOAT(value);
534  }
535  else {
536  *dst++ = (GLfloat) value;
537  }
538  }
539  }
540  else {
541  if (normalize) {
542  for (j=0;j<elems_per_row;j++) {
543  *dst++ = SHORT_TO_FLOAT(((GLshort*)src)[j]);
544  }
545  }
546  else {
547  for (j=0;j<elems_per_row;j++) {
548  *dst++ = (GLfloat) ((GLshort*)src)[j];
549  }
550  }
551  }
552  break;
553  case GL_UNSIGNED_INT:
554  if (ctx->Unpack.SwapBytes) {
555  GLuint value;
556  for (j=0;j<elems_per_row;j++) {
557  value = ((GLuint*)src)[j];
558  value = ((value & 0xff000000) >> 24)
559  | ((value & 0x00ff0000) >> 8)
560  | ((value & 0x0000ff00) << 8)
561  | ((value & 0x000000ff) << 24);
562  if (normalize) {
563  *dst++ = UINT_TO_FLOAT(value);
564  }
565  else {
566  *dst++ = (GLfloat) value;
567  }
568  }
569  }
570  else {
571  if (normalize) {
572  for (j=0;j<elems_per_row;j++) {
573  *dst++ = UINT_TO_FLOAT(((GLuint*)src)[j]);
574  }
575  }
576  else {
577  for (j=0;j<elems_per_row;j++) {
578  *dst++ = (GLfloat) ((GLuint*)src)[j];
579  }
580  }
581  }
582  break;
583  case GL_INT:
584  if (ctx->Unpack.SwapBytes) {
585  GLint value;
586  for (j=0;j<elems_per_row;j++) {
587  value = ((GLint*)src)[j];
588  value = ((value & 0xff000000) >> 24)
589  | ((value & 0x00ff0000) >> 8)
590  | ((value & 0x0000ff00) << 8)
591  | ((value & 0x000000ff) << 24);
592  if (normalize) {
593  *dst++ = INT_TO_FLOAT(value);
594  }
595  else {
596  *dst++ = (GLfloat) value;
597  }
598  }
599  }
600  else {
601  if (normalize) {
602  for (j=0;j<elems_per_row;j++) {
603  *dst++ = INT_TO_FLOAT(((GLint*)src)[j]);
604  }
605  }
606  else {
607  for (j=0;j<elems_per_row;j++) {
608  *dst++ = (GLfloat) ((GLint*)src)[j];
609  }
610  }
611  }
612  break;
613  case GL_FLOAT:
614  if (ctx->Unpack.SwapBytes) {
615  GLint value;
616  for (j=0;j<elems_per_row;j++) {
617  value = ((GLuint*)src)[j];
618  value = ((value & 0xff000000) >> 24)
619  | ((value & 0x00ff0000) >> 8)
620  | ((value & 0x0000ff00) << 8)
621  | ((value & 0x000000ff) << 24);
622  *dst++ = *((GLfloat*) &value);
623  }
624  }
625  else {
626  MEMCPY( dst, src, elems_per_row*sizeof(GLfloat) );
627  dst += elems_per_row;
628  }
629  break;
630  default:
631  gl_problem(ctx, "Bad type in gl_unpack_image3D");
632  return NULL;
633  } /*switch*/
634  } /* for height */
635 
636  image = (struct gl_image *) malloc( sizeof(struct gl_image) );
637  if (image) {
638  image->Width = width;
639  image->Height = height;
640  image->Components = components;
641  image->Format = srcFormat;
642  image->Type = GL_FLOAT;
643  image->Data = buffer;
644  image->RefCount = 0;
645  }
646  else {
647  free( buffer );
648  return NULL;
649  }
650  return image;
651  }
652  else {
653  gl_problem(ctx, "Bad dest type in gl_unpack_image3D");
654  return NULL;
655  }
656  return NULL; /* never get here */
657 }
#define UBYTE_TO_FLOAT(B)
Definition: macros.h:180
#define GL_INT
Definition: gl.h:181
#define GL_UNSIGNED_SHORT
Definition: gl.h:180
GLeglImageOES image
Definition: gl.h:2204
GLint GLint GLsizei width
Definition: gl.h:1546
#define GL_BITMAP
Definition: gl.h:497
unsigned char GLubyte
Definition: gl.h:157
#define INT_TO_FLOAT(I)
Definition: macros.h:215
#define free
Definition: debug_ros.c:5
static void normalize(float vec[3])
Definition: bezierEval.cc:234
#define GL_UNSIGNED_BYTE
Definition: gl.h:178
#define GL_FLOAT
Definition: gl.h:183
#define assert(x)
Definition: debug.h:53
GLuint buffer
Definition: glext.h:5915
#define CEILING(A, B)
Definition: macros.h:151
#define SHORT_TO_FLOAT(S)
Definition: macros.h:201
#define GL_SHORT
Definition: gl.h:179
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
unsigned char GLboolean
Definition: gl.h:151
smooth NULL
Definition: ftsmooth.c:416
void gl_flip_bytes(GLubyte *p, GLuint n)
Definition: image.c:105
#define GL_UNSIGNED_INT
Definition: gl.h:182
#define USHORT_TO_FLOAT(S)
Definition: macros.h:194
#define BYTE_TO_FLOAT(B)
Definition: macros.h:187
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define MEMCPY(DST, SRC, BYTES)
Definition: macros.h:231
#define GL_STENCIL_INDEX
Definition: gl.h:458
GLenum GLenum GLuint components
Definition: glext.h:9620
signed char GLbyte
Definition: gl.h:154
GLint gl_components_in_format(GLenum format)
Definition: image.c:193
GLenum src
Definition: glext.h:6340
unsigned int GLenum
Definition: gl.h:150
GLsizei const GLfloat * value
Definition: glext.h:6069
void gl_problem(const GLcontext *ctx, const char *s)
Definition: context.c:1394
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define GL_BYTE
Definition: gl.h:177
short GLshort
Definition: gl.h:155
#define GL_DEPTH_COMPONENT
Definition: gl.h:307
unsigned int GLuint
Definition: gl.h:159
struct gl_pixelstore_attrib Unpack
Definition: types.h:1344
#define GL_COLOR_INDEX
Definition: gl.h:479
GLvoid * gl_pixel_addr_in_image(struct gl_pixelstore_attrib *packing, const GLvoid *image, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint row)
Definition: image.c:232
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: gl.h:1546
GLenum GLenum dst
Definition: glext.h:6340
float GLfloat
Definition: gl.h:161
int GLint
Definition: gl.h:156
#define malloc
Definition: debug_ros.c:4
#define UINT_TO_FLOAT(U)
Definition: macros.h:208
unsigned short GLushort
Definition: gl.h:158

Referenced by _mesa_ColorSubTableEXT(), _mesa_ColorTableEXT(), _mesa_TexImage1D(), _mesa_TexImage2D(), gl_unpack_bitmap(), and gl_unpack_texsubimage().