Merge commit 'origin/7.8'
[mesa.git] / src / mesa / main / debug.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 6.5
4 *
5 * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
6 * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 */
25
26 #include "mtypes.h"
27 #include "attrib.h"
28 #include "colormac.h"
29 #include "enums.h"
30 #include "formats.h"
31 #include "hash.h"
32 #include "imports.h"
33 #include "debug.h"
34 #include "get.h"
35 #include "pixelstore.h"
36 #include "readpix.h"
37 #include "texobj.h"
38
39
40 /**
41 * Primitive names
42 */
43 const char *_mesa_prim_name[GL_POLYGON+4] = {
44 "GL_POINTS",
45 "GL_LINES",
46 "GL_LINE_LOOP",
47 "GL_LINE_STRIP",
48 "GL_TRIANGLES",
49 "GL_TRIANGLE_STRIP",
50 "GL_TRIANGLE_FAN",
51 "GL_QUADS",
52 "GL_QUAD_STRIP",
53 "GL_POLYGON",
54 "outside begin/end",
55 "inside unknown primitive",
56 "unknown state"
57 };
58
59
60 static const char *
61 tex_target_name(GLenum tgt)
62 {
63 static const struct {
64 GLenum target;
65 const char *name;
66 } tex_targets[] = {
67 { GL_TEXTURE_1D, "GL_TEXTURE_1D" },
68 { GL_TEXTURE_2D, "GL_TEXTURE_2D" },
69 { GL_TEXTURE_3D, "GL_TEXTURE_3D" },
70 { GL_TEXTURE_CUBE_MAP, "GL_TEXTURE_CUBE_MAP" },
71 { GL_TEXTURE_RECTANGLE, "GL_TEXTURE_RECTANGLE" },
72 { GL_TEXTURE_1D_ARRAY_EXT, "GL_TEXTURE_1D_ARRAY" },
73 { GL_TEXTURE_2D_ARRAY_EXT, "GL_TEXTURE_2D_ARRAY" }
74 };
75 GLuint i;
76 for (i = 0; i < Elements(tex_targets); i++) {
77 if (tex_targets[i].target == tgt)
78 return tex_targets[i].name;
79 }
80 return "UNKNOWN TEX TARGET";
81 }
82
83
84 void
85 _mesa_print_state( const char *msg, GLuint state )
86 {
87 _mesa_debug(NULL,
88 "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
89 msg,
90 state,
91 (state & _NEW_MODELVIEW) ? "ctx->ModelView, " : "",
92 (state & _NEW_PROJECTION) ? "ctx->Projection, " : "",
93 (state & _NEW_TEXTURE_MATRIX) ? "ctx->TextureMatrix, " : "",
94 (state & _NEW_COLOR_MATRIX) ? "ctx->ColorMatrix, " : "",
95 (state & _NEW_ACCUM) ? "ctx->Accum, " : "",
96 (state & _NEW_COLOR) ? "ctx->Color, " : "",
97 (state & _NEW_DEPTH) ? "ctx->Depth, " : "",
98 (state & _NEW_EVAL) ? "ctx->Eval/EvalMap, " : "",
99 (state & _NEW_FOG) ? "ctx->Fog, " : "",
100 (state & _NEW_HINT) ? "ctx->Hint, " : "",
101 (state & _NEW_LIGHT) ? "ctx->Light, " : "",
102 (state & _NEW_LINE) ? "ctx->Line, " : "",
103 (state & _NEW_PIXEL) ? "ctx->Pixel, " : "",
104 (state & _NEW_POINT) ? "ctx->Point, " : "",
105 (state & _NEW_POLYGON) ? "ctx->Polygon, " : "",
106 (state & _NEW_POLYGONSTIPPLE) ? "ctx->PolygonStipple, " : "",
107 (state & _NEW_SCISSOR) ? "ctx->Scissor, " : "",
108 (state & _NEW_STENCIL) ? "ctx->Stencil, " : "",
109 (state & _NEW_TEXTURE) ? "ctx->Texture, " : "",
110 (state & _NEW_TRANSFORM) ? "ctx->Transform, " : "",
111 (state & _NEW_VIEWPORT) ? "ctx->Viewport, " : "",
112 (state & _NEW_PACKUNPACK) ? "ctx->Pack/Unpack, " : "",
113 (state & _NEW_ARRAY) ? "ctx->Array, " : "",
114 (state & _NEW_RENDERMODE) ? "ctx->RenderMode, " : "",
115 (state & _NEW_BUFFERS) ? "ctx->Visual, ctx->DrawBuffer,, " : "");
116 }
117
118
119
120 void
121 _mesa_print_tri_caps( const char *name, GLuint flags )
122 {
123 _mesa_debug(NULL,
124 "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
125 name,
126 flags,
127 (flags & DD_FLATSHADE) ? "flat-shade, " : "",
128 (flags & DD_SEPARATE_SPECULAR) ? "separate-specular, " : "",
129 (flags & DD_TRI_LIGHT_TWOSIDE) ? "tri-light-twoside, " : "",
130 (flags & DD_TRI_TWOSTENCIL) ? "tri-twostencil, " : "",
131 (flags & DD_TRI_UNFILLED) ? "tri-unfilled, " : "",
132 (flags & DD_TRI_STIPPLE) ? "tri-stipple, " : "",
133 (flags & DD_TRI_OFFSET) ? "tri-offset, " : "",
134 (flags & DD_TRI_SMOOTH) ? "tri-smooth, " : "",
135 (flags & DD_LINE_SMOOTH) ? "line-smooth, " : "",
136 (flags & DD_LINE_STIPPLE) ? "line-stipple, " : "",
137 (flags & DD_LINE_WIDTH) ? "line-wide, " : "",
138 (flags & DD_POINT_SMOOTH) ? "point-smooth, " : "",
139 (flags & DD_POINT_SIZE) ? "point-size, " : "",
140 (flags & DD_POINT_ATTEN) ? "point-atten, " : "",
141 (flags & DD_TRI_CULL_FRONT_BACK) ? "cull-all, " : ""
142 );
143 }
144
145
146 /**
147 * Print information about this Mesa version and build options.
148 */
149 void _mesa_print_info( void )
150 {
151 _mesa_debug(NULL, "Mesa GL_VERSION = %s\n",
152 (char *) _mesa_GetString(GL_VERSION));
153 _mesa_debug(NULL, "Mesa GL_RENDERER = %s\n",
154 (char *) _mesa_GetString(GL_RENDERER));
155 _mesa_debug(NULL, "Mesa GL_VENDOR = %s\n",
156 (char *) _mesa_GetString(GL_VENDOR));
157 _mesa_debug(NULL, "Mesa GL_EXTENSIONS = %s\n",
158 (char *) _mesa_GetString(GL_EXTENSIONS));
159 #if defined(THREADS)
160 _mesa_debug(NULL, "Mesa thread-safe: YES\n");
161 #else
162 _mesa_debug(NULL, "Mesa thread-safe: NO\n");
163 #endif
164 #if defined(USE_X86_ASM)
165 _mesa_debug(NULL, "Mesa x86-optimized: YES\n");
166 #else
167 _mesa_debug(NULL, "Mesa x86-optimized: NO\n");
168 #endif
169 #if defined(USE_SPARC_ASM)
170 _mesa_debug(NULL, "Mesa sparc-optimized: YES\n");
171 #else
172 _mesa_debug(NULL, "Mesa sparc-optimized: NO\n");
173 #endif
174 }
175
176
177 /**
178 * Set the debugging flags.
179 *
180 * \param debug debug string
181 *
182 * If compiled with debugging support then search for keywords in \p debug and
183 * enables the verbose debug output of the respective feature.
184 */
185 static void add_debug_flags( const char *debug )
186 {
187 #ifdef DEBUG
188 struct debug_option {
189 const char *name;
190 GLbitfield flag;
191 };
192 static const struct debug_option debug_opt[] = {
193 { "varray", VERBOSE_VARRAY },
194 { "tex", VERBOSE_TEXTURE },
195 { "mat", VERBOSE_MATERIAL },
196 { "pipe", VERBOSE_PIPELINE },
197 { "driver", VERBOSE_DRIVER },
198 { "state", VERBOSE_STATE },
199 { "api", VERBOSE_API },
200 { "list", VERBOSE_DISPLAY_LIST },
201 { "lighting", VERBOSE_LIGHTING },
202 { "disassem", VERBOSE_DISASSEM },
203 { "draw", VERBOSE_DRAW },
204 { "swap", VERBOSE_SWAPBUFFERS }
205 };
206 GLuint i;
207
208 MESA_VERBOSE = 0x0;
209 for (i = 0; i < Elements(debug_opt); i++) {
210 if (strstr(debug, debug_opt[i].name))
211 MESA_VERBOSE |= debug_opt[i].flag;
212 }
213
214 /* Debug flag:
215 */
216 if (strstr(debug, "flush"))
217 MESA_DEBUG_FLAGS |= DEBUG_ALWAYS_FLUSH;
218
219 #if defined(_FPU_GETCW) && defined(_FPU_SETCW)
220 if (strstr(debug, "fpexceptions")) {
221 /* raise FP exceptions */
222 fpu_control_t mask;
223 _FPU_GETCW(mask);
224 mask &= ~(_FPU_MASK_IM | _FPU_MASK_DM | _FPU_MASK_ZM
225 | _FPU_MASK_OM | _FPU_MASK_UM);
226 _FPU_SETCW(mask);
227 }
228 #endif
229
230 #else
231 (void) debug;
232 #endif
233 }
234
235
236 void
237 _mesa_init_debug( GLcontext *ctx )
238 {
239 char *c;
240
241 /* Dither disable */
242 ctx->NoDither = _mesa_getenv("MESA_NO_DITHER") ? GL_TRUE : GL_FALSE;
243 if (ctx->NoDither) {
244 if (_mesa_getenv("MESA_DEBUG")) {
245 _mesa_debug(ctx, "MESA_NO_DITHER set - dithering disabled\n");
246 }
247 ctx->Color.DitherFlag = GL_FALSE;
248 }
249
250 c = _mesa_getenv("MESA_DEBUG");
251 if (c)
252 add_debug_flags(c);
253
254 c = _mesa_getenv("MESA_VERBOSE");
255 if (c)
256 add_debug_flags(c);
257 }
258
259
260 /*
261 * Write ppm file
262 */
263 static void
264 write_ppm(const char *filename, const GLubyte *buffer, int width, int height,
265 int comps, int rcomp, int gcomp, int bcomp, GLboolean invert)
266 {
267 FILE *f = fopen( filename, "w" );
268 if (f) {
269 int x, y;
270 const GLubyte *ptr = buffer;
271 fprintf(f,"P6\n");
272 fprintf(f,"# ppm-file created by osdemo.c\n");
273 fprintf(f,"%i %i\n", width,height);
274 fprintf(f,"255\n");
275 fclose(f);
276 f = fopen( filename, "ab" ); /* reopen in binary append mode */
277 for (y=0; y < height; y++) {
278 for (x = 0; x < width; x++) {
279 int yy = invert ? (height - 1 - y) : y;
280 int i = (yy * width + x) * comps;
281 fputc(ptr[i+rcomp], f); /* write red */
282 fputc(ptr[i+gcomp], f); /* write green */
283 fputc(ptr[i+bcomp], f); /* write blue */
284 }
285 }
286 fclose(f);
287 }
288 }
289
290
291 /**
292 * Write a texture image to a ppm file.
293 * \param face cube face in [0,5]
294 * \param level mipmap level
295 */
296 static void
297 write_texture_image(struct gl_texture_object *texObj,
298 GLuint face, GLuint level)
299 {
300 struct gl_texture_image *img = texObj->Image[face][level];
301 if (img) {
302 GET_CURRENT_CONTEXT(ctx);
303 struct gl_pixelstore_attrib store;
304 GLubyte *buffer;
305 char s[100];
306
307 buffer = (GLubyte *) malloc(img->Width * img->Height
308 * img->Depth * 4);
309
310 store = ctx->Pack; /* save */
311 ctx->Pack = ctx->DefaultPacking;
312
313 ctx->Driver.GetTexImage(ctx, texObj->Target, level,
314 GL_RGBA, GL_UNSIGNED_BYTE,
315 buffer, texObj, img);
316
317 /* make filename */
318 sprintf(s, "/tmp/tex%u.l%u.f%u.ppm", texObj->Name, level, face);
319
320 printf(" Writing image level %u to %s\n", level, s);
321 write_ppm(s, buffer, img->Width, img->Height, 4, 0, 1, 2, GL_FALSE);
322
323 ctx->Pack = store; /* restore */
324
325 free(buffer);
326 }
327 }
328
329
330 /**
331 * Write renderbuffer image to a ppm file.
332 */
333 static void
334 write_renderbuffer_image(const struct gl_renderbuffer *rb)
335 {
336 GET_CURRENT_CONTEXT(ctx);
337 GLubyte *buffer;
338 char s[100];
339 GLenum format, type;
340
341 if (rb->_BaseFormat == GL_RGB ||
342 rb->_BaseFormat == GL_RGBA) {
343 format = GL_RGBA;
344 type = GL_UNSIGNED_BYTE;
345 }
346 else if (rb->_BaseFormat == GL_DEPTH_STENCIL) {
347 format = GL_DEPTH_STENCIL;
348 type = GL_UNSIGNED_INT_24_8;
349 }
350 else {
351 return;
352 }
353
354 buffer = (GLubyte *) malloc(rb->Width * rb->Height * 4);
355
356 ctx->Driver.ReadPixels(ctx, 0, 0, rb->Width, rb->Height,
357 format, type, &ctx->DefaultPacking, buffer);
358
359 /* make filename */
360 sprintf(s, "/tmp/renderbuffer%u.ppm", rb->Name);
361
362 printf(" Writing renderbuffer image to %s\n", s);
363 write_ppm(s, buffer, rb->Width, rb->Height, 4, 0, 1, 2, GL_TRUE);
364
365 free(buffer);
366 }
367
368
369 /** How many texture images (mipmap levels, faces) to write to files */
370 #define WRITE_NONE 0
371 #define WRITE_ONE 1
372 #define WRITE_ALL 2
373
374 static GLuint WriteImages;
375
376
377 static void
378 dump_texture(struct gl_texture_object *texObj, GLuint writeImages)
379 {
380 const GLuint numFaces = texObj->Target == GL_TEXTURE_CUBE_MAP ? 6 : 1;
381 GLboolean written = GL_FALSE;
382 GLuint i, j;
383
384 printf("Texture %u\n", texObj->Name);
385 printf(" Target %s\n", tex_target_name(texObj->Target));
386 for (i = 0; i < MAX_TEXTURE_LEVELS; i++) {
387 for (j = 0; j < numFaces; j++) {
388 struct gl_texture_image *texImg = texObj->Image[j][i];
389 if (texImg) {
390 printf(" Face %u level %u: %d x %d x %d, format %s at %p\n",
391 j, i,
392 texImg->Width, texImg->Height, texImg->Depth,
393 _mesa_get_format_name(texImg->TexFormat),
394 texImg->Data);
395 if (writeImages == WRITE_ALL ||
396 (writeImages == WRITE_ONE && !written)) {
397 write_texture_image(texObj, j, i);
398 written = GL_TRUE;
399 }
400 }
401 }
402 }
403 }
404
405
406 /**
407 * Dump a single texture.
408 */
409 void
410 _mesa_dump_texture(GLuint texture, GLuint writeImages)
411 {
412 GET_CURRENT_CONTEXT(ctx);
413 struct gl_texture_object *texObj = _mesa_lookup_texture(ctx, texture);
414 if (texObj) {
415 dump_texture(texObj, writeImages);
416 }
417 }
418
419
420 static void
421 dump_texture_cb(GLuint id, void *data, void *userData)
422 {
423 struct gl_texture_object *texObj = (struct gl_texture_object *) data;
424 (void) userData;
425 dump_texture(texObj, WriteImages);
426 }
427
428
429 /**
430 * Print basic info about all texture objext to stdout.
431 * If dumpImages is true, write PPM of level[0] image to a file.
432 */
433 void
434 _mesa_dump_textures(GLuint writeImages)
435 {
436 GET_CURRENT_CONTEXT(ctx);
437 WriteImages = writeImages;
438 _mesa_HashWalk(ctx->Shared->TexObjects, dump_texture_cb, ctx);
439 }
440
441
442 static void
443 dump_renderbuffer(const struct gl_renderbuffer *rb, GLboolean writeImage)
444 {
445 printf("Renderbuffer %u: %u x %u IntFormat = %s\n",
446 rb->Name, rb->Width, rb->Height,
447 _mesa_lookup_enum_by_nr(rb->InternalFormat));
448 if (writeImage) {
449 write_renderbuffer_image(rb);
450 }
451 }
452
453
454 static void
455 dump_renderbuffer_cb(GLuint id, void *data, void *userData)
456 {
457 const struct gl_renderbuffer *rb = (const struct gl_renderbuffer *) data;
458 (void) userData;
459 dump_renderbuffer(rb, WriteImages);
460 }
461
462
463 /**
464 * Print basic info about all renderbuffers to stdout.
465 * If dumpImages is true, write PPM of level[0] image to a file.
466 */
467 void
468 _mesa_dump_renderbuffers(GLboolean writeImages)
469 {
470 GET_CURRENT_CONTEXT(ctx);
471 WriteImages = writeImages;
472 _mesa_HashWalk(ctx->Shared->RenderBuffers, dump_renderbuffer_cb, ctx);
473 }
474
475
476
477 void
478 _mesa_dump_color_buffer(const char *filename)
479 {
480 GET_CURRENT_CONTEXT(ctx);
481 const GLuint w = ctx->DrawBuffer->Width;
482 const GLuint h = ctx->DrawBuffer->Height;
483 GLubyte *buf;
484
485 buf = (GLubyte *) malloc(w * h * 4);
486
487 _mesa_PushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
488 _mesa_PixelStorei(GL_PACK_ALIGNMENT, 1);
489 _mesa_PixelStorei(GL_PACK_INVERT_MESA, GL_TRUE);
490
491 _mesa_ReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, buf);
492
493 printf("ReadBuffer %p 0x%x DrawBuffer %p 0x%x\n",
494 (void *) ctx->ReadBuffer->_ColorReadBuffer,
495 ctx->ReadBuffer->ColorReadBuffer,
496 (void *) ctx->DrawBuffer->_ColorDrawBuffers[0],
497 ctx->DrawBuffer->ColorDrawBuffer[0]);
498 printf("Writing %d x %d color buffer to %s\n", w, h, filename);
499 write_ppm(filename, buf, w, h, 4, 0, 1, 2, GL_TRUE);
500
501 _mesa_PopClientAttrib();
502
503 free(buf);
504 }
505
506
507 void
508 _mesa_dump_depth_buffer(const char *filename)
509 {
510 GET_CURRENT_CONTEXT(ctx);
511 const GLuint w = ctx->DrawBuffer->Width;
512 const GLuint h = ctx->DrawBuffer->Height;
513 GLuint *buf;
514 GLubyte *buf2;
515 GLuint i;
516
517 buf = (GLuint *) malloc(w * h * 4); /* 4 bpp */
518 buf2 = (GLubyte *) malloc(w * h * 3); /* 3 bpp */
519
520 _mesa_PushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
521 _mesa_PixelStorei(GL_PACK_ALIGNMENT, 1);
522 _mesa_PixelStorei(GL_PACK_INVERT_MESA, GL_TRUE);
523
524 _mesa_ReadPixels(0, 0, w, h, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, buf);
525
526 /* spread 24 bits of Z across R, G, B */
527 for (i = 0; i < w * h; i++) {
528 buf2[i*3+0] = (buf[i] >> 24) & 0xff;
529 buf2[i*3+1] = (buf[i] >> 16) & 0xff;
530 buf2[i*3+2] = (buf[i] >> 8) & 0xff;
531 }
532
533 printf("Writing %d x %d depth buffer to %s\n", w, h, filename);
534 write_ppm(filename, buf2, w, h, 3, 0, 1, 2, GL_TRUE);
535
536 _mesa_PopClientAttrib();
537
538 free(buf);
539 free(buf2);
540 }
541
542
543 void
544 _mesa_dump_stencil_buffer(const char *filename)
545 {
546 GET_CURRENT_CONTEXT(ctx);
547 const GLuint w = ctx->DrawBuffer->Width;
548 const GLuint h = ctx->DrawBuffer->Height;
549 GLubyte *buf;
550 GLubyte *buf2;
551 GLuint i;
552
553 buf = (GLubyte *) malloc(w * h); /* 1 bpp */
554 buf2 = (GLubyte *) malloc(w * h * 3); /* 3 bpp */
555
556 _mesa_PushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
557 _mesa_PixelStorei(GL_PACK_ALIGNMENT, 1);
558 _mesa_PixelStorei(GL_PACK_INVERT_MESA, GL_TRUE);
559
560 _mesa_ReadPixels(0, 0, w, h, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, buf);
561
562 for (i = 0; i < w * h; i++) {
563 buf2[i*3+0] = buf[i];
564 buf2[i*3+1] = (buf[i] & 127) * 2;
565 buf2[i*3+2] = (buf[i] - 128) * 2;
566 }
567
568 printf("Writing %d x %d stencil buffer to %s\n", w, h, filename);
569 write_ppm(filename, buf2, w, h, 3, 0, 1, 2, GL_TRUE);
570
571 _mesa_PopClientAttrib();
572
573 free(buf);
574 free(buf2);
575 }
576
577
578 /**
579 * Quick and dirty function to "print" a texture to stdout.
580 */
581 void
582 _mesa_print_texture(GLcontext *ctx, const struct gl_texture_image *img)
583 {
584 #if CHAN_TYPE != GL_UNSIGNED_BYTE
585 _mesa_problem(NULL, "PrintTexture not supported");
586 #else
587 GLuint i, j, c;
588 const GLubyte *data = (const GLubyte *) img->Data;
589
590 if (!data) {
591 printf("No texture data\n");
592 return;
593 }
594
595 /* XXX add more formats or make into a new format utility function */
596 switch (img->TexFormat) {
597 case MESA_FORMAT_A8:
598 case MESA_FORMAT_L8:
599 case MESA_FORMAT_I8:
600 case MESA_FORMAT_CI8:
601 c = 1;
602 break;
603 case MESA_FORMAT_AL88:
604 case MESA_FORMAT_AL88_REV:
605 c = 2;
606 break;
607 case MESA_FORMAT_RGB888:
608 case MESA_FORMAT_BGR888:
609 c = 3;
610 break;
611 case MESA_FORMAT_RGBA8888:
612 case MESA_FORMAT_ARGB8888:
613 c = 4;
614 break;
615 default:
616 _mesa_problem(NULL, "error in PrintTexture\n");
617 return;
618 }
619
620 for (i = 0; i < img->Height; i++) {
621 for (j = 0; j < img->Width; j++) {
622 if (c==1)
623 printf("%02x ", data[0]);
624 else if (c==2)
625 printf("%02x%02x ", data[0], data[1]);
626 else if (c==3)
627 printf("%02x%02x%02x ", data[0], data[1], data[2]);
628 else if (c==4)
629 printf("%02x%02x%02x%02x ", data[0], data[1], data[2], data[3]);
630 data += (img->RowStride - img->Width) * c;
631 }
632 /* XXX use img->ImageStride here */
633 printf("\n");
634 }
635 #endif
636 }