00001 /*============================================================================ 00002 * Image Debugging API 00003 * 00004 * This API can simplify the debugging of applications that handle 2D data. 00005 * It basically allows you to do 'printf' style debugging of images in 00006 * C and C++ applications. 00007 * 00008 * Basic Usage: 00009 * #include <imdebug.h> 00010 * ... 00011 * imdebug(format_string, ...); 00012 * 00013 * The format string describes the type of image(s) to dump to the debug 00014 * window. Here are some examples 00015 * 00016 * Show an rgb image with width and height 16: 00017 * 00018 * imdebug("rgb w=%d h=%d %p", 16, 16, img); 00019 * 00020 * VARIABLE SPEC: 00021 * %d - int 00022 * %f - float 00023 * %s - string 00024 * %p - picture (pointer to raw image data) 00025 * 00026 * INPUT FORMAT SPEC: 00027 * rgb 00028 * bgr 00029 * abgr 00030 * rgba... - specify input image channel order 00031 * lum - 1-channel image: lumninance 00032 * luma - 2-channel image: lumninance + alpha 00033 * #5 - 5-channel data (default is to use 0,1,2 as RGB, no alpha) 00034 * ---> (default is rgb) 00035 * 00036 * b=8 - size of all channels is 8 bits 00037 * b=5,6,5 - size of channels is 5bits(R) 6bits(G) 5bits(B) 00038 * b=32f - size of all channels is 32 bits, float format 00039 * ---> (default is b=8) 00040 * 00041 * OUTPUT FORMAT SPEC: 00042 * rgba=rg__ - just display the red and green chanels 00043 * rgba=aaa_ - display alpha as grayscale 00044 * lum=g - display green as grayscale 00045 * rgb=#A1C - r:=chan 10, g:=chan 1, b:=chan 12 (use HEX digits!) 00046 * ---> (default is 1-1 mapping with no translation or swizzling) 00047 * 00048 * ATTRIBUTE SPEC: 00049 * w=23 - width is 23 (default 0) 00050 * h=17 - height is 17 (default 0) 00051 * rs=1 - skip 1 row after every row (default 0) 00052 * cs=2 - skip 2 columns after every column (default 0) 00053 * 00054 * SCALE AND BIAS: 00055 * *1.2 - scale RGB by 1.2 00056 * /1.2 - scale RGB by 1/1.2 00057 * +128 - bias RGB by 128 00058 * -0.5 - bias RGB by -0.5 00059 * r*1.2 - scale red by 1.2 00060 * rb/1.2 - scale both red and blue by 1/1.2 00061 * a+128 - bias alpha by 128 00062 * rgba-0.5 - bias RGB and alpha by -0.5 00063 * *auto - automatically scale & bias RGB based on max & min values 00064 * ra*auto - automatically scale & bias red and alpha 00065 * --> Default is scale=1 and bias=0 for all channels 00066 * --> Output value is computed as (x*scale)+bias, 00067 * the same order as with OpenGL glPixelTransfer functions. 00068 * 00069 * Order of specifiers is mostly not important, but channel swizzeling 00070 * should come after input format specifier. 00071 * (i.e. do "rgb bgr=rgb", not "bgr=rgb rgb") 00072 * 00073 * If no image is specified (with '%p'), then the previous 00074 * image data is used. 00075 * 00076 * THOUGHTS FOR THE FUTURE 00077 * 00078 * handling raw graphic images in compressed form. e.g.: 00079 * %pj = specify raw jpg image buffer 00080 * %pp = specify raw png image buffer 00081 * %pb = specify raw bmp image buffer 00082 * 00083 * A way to perform math on images in the format specifier, 00084 * or perform other arbitrary transformations on the input. 00085 * Like "%p - 0.5*%p" 00086 * 00087 * A way to specify that several images should be tiled, 00088 * or opened in separate display windows. 00089 * 00090 * More control over padding and alignment specs. 00091 * 00092 * Ooops! Really should allow specification of endianness! 00093 * That would be handy for data not created in the local endian format. 00094 * 00095 * Author: William Baxter (baxter@cs.unc.edu) 00096 * Created: Sept 2002 00097 * Last Modified: Jan 2003 00098 *============================================================================ 00099 * Copyright 2002 00100 * William Baxter 00101 * The University of North Carolina at Chapel Hill 00102 * 00103 * Permission to use, copy, modify, distribute and sell this software 00104 * and its documentation for any purpose is hereby granted without 00105 * fee, provided that the above copyright notice appear in all copies 00106 * and that both that copyright notice and this permission notice 00107 * appear in supporting documentation. Binaries may be compiled with 00108 * this software without any royalties or restrictions. 00109 * 00110 * The University of North Carolina at Chapel Hill makes no 00111 * representations about the suitability of this software for any 00112 * purpose. It is provided "as is" without express or implied 00113 * warranty. 00114 *============================================================================ 00115 */ 00116 00117 00118 #ifndef IMDEBUG_H 00119 #define IMDEBUG_H 00120 00121 #ifdef __cplusplus 00122 extern "C" { 00123 #endif 00124 00125 #ifndef WIN32_LEAN_AND_MEAN 00126 #define WIN32_LEAN_AND_MEAN 00127 #endif 00128 #include <windows.h> 00129 00130 #ifndef IMDBG_EXPORT 00131 #define IMDBG_EXPORT __declspec(dllimport) 00132 #pragma comment (lib, "imdebug.lib") 00133 #else 00134 #endif 00135 00136 /*===========================================================================*/ 00137 /* */ 00138 /* This is it. The one function you need to know about: */ 00139 00140 IMDBG_EXPORT void CALLBACK imdebug(const char *format, ...); 00141 00142 /*===========================================================================*/ 00143 00144 #ifdef __cplusplus 00145 } /* end extern "C" */ 00146 #endif 00147 00148 #endif /* IMDEBUG_H */
1.4.6