#include <displayer.h>
Inheritance diagram for Displayer:

Public Member Functions | |
| virtual | ~Displayer () |
| virtual bool | usable () |
| Indicates if an object can be used to render images on the running system. | |
| virtual DisplayerInput | format () |
| Indicates the format required by the abstract put method. | |
| virtual int | preferredWidth () |
| Expect width of input to put. | |
| virtual int | preferredHeight () |
| Expect width of input to put. | |
| virtual void | put (void *image, int width, int height) |
| Put an image of a given width and height with the expected input format (as indicated by the format method). | |
| virtual void | put (DisplayerInput inFormat, void *image, int width, int height) |
| Put an image of a given width and height with the input format specified. | |
Protected Member Functions | |
| virtual void | put (void *)=0 |
Protected Attributes | |
| int | img_width |
| int | img_height |
Private Member Functions | |
| void | reformat (DisplayerInput inFormat, int outFormat, void *image, int width, int height) |
| Reformat. | |
| void | Reformat424 (unsigned char *image, int inWidth, int inHeight, int outWidth, int outHeight) |
| void | Reformat222 (unsigned char *image, int inWidth, int inHeight, int outWidth, int outHeight) |
| void | Reformat323 (unsigned char *image, int inWidth, int inHeight, int outWidth, int outHeight) |
| void | Reformat323R (unsigned char *image, int inWidth, int inHeight, int outWidth, int outHeight) |
| void | Reformat324 (unsigned char *image, int inWidth, int inHeight, int outWidth, int outHeight) |
Private Attributes | |
| unsigned char | pixels [MAX_WIDTH *MAX_HEIGHT *4] |
All Displayer classes must extend the Displayer class and minimally rewrite:
+ usable() - to indicate if the object can be used, + format() - to indicate what type of input the put method expects + put( void * ) - deal with an image of the expected type and size
By default, all images will be delivered to the put method in a resolution of IMG_WIDTH * IMG_HEIGHT. If another size is required, then the rewrite the methods:
+ preferredWidth + preferredHeight
If the widget being written to doesn't need a fixed size, then rewrite the two other put methods as required.
Definition at line 104 of file displayer.h.
|
|
Definition at line 112 of file displayer.h. 00113 { }
|
|
|
Indicates the format required by the abstract put method.
Reimplemented in XDisplayer, XvDisplayer, and GdkDisplayer. Definition at line 129 of file displayer.cc. References DISPLAY_NONE. Referenced by GDKV4L::capture(), GDKV4L::draw(), FrameDisplayer::Put(), and put(). 00130 {
00131 return DISPLAY_NONE;
00132 }
|
|
|
Expect width of input to put.
Definition at line 145 of file displayer.cc. References img_height. Referenced by GdkDisplayer::put(), XvDisplayer::put(), XDisplayer::put(), put(), reformat(), and XDisplayer::XDisplayer(). 00146 {
00147 return img_height;
00148 }
|
|
|
Expect width of input to put.
Definition at line 137 of file displayer.cc. References img_width. Referenced by GdkDisplayer::put(), and put(). 00138 {
00139 return img_width;
00140 }
|
|
||||||||||||||||||||
|
Put an image of a given width and height with the input format specified.
Definition at line 181 of file displayer.cc. References format(), pixels, preferredHeight(), preferredWidth(), put(), and reformat(). 00183 {
00184 if ( format() == inFormat &&
00185 width == preferredWidth() && height == preferredHeight() )
00186 {
00187 put( image );
00188 }
00189 else
00190 {
00191 reformat( inFormat, format(), image, width, height );
00192 put( pixels );
00193 }
00194 }
|
|
||||||||||||||||
|
Put an image of a given width and height with the expected input format (as indicated by the format method).
Definition at line 158 of file displayer.cc. References format(), pixels, preferredHeight(), preferredWidth(), put(), and reformat(). 00159 {
00160 if ( width == preferredWidth() && height == preferredHeight() )
00161 {
00162 put( image );
00163 }
00164 else
00165 {
00166 reformat( format(), format(), image, width, height );
00167 put( pixels );
00168 }
00169 }
|
|
|
Implemented in XDisplayer, XvDisplayer, and GdkDisplayer. Referenced by GDKV4L::capture(), GDKV4L::draw(), FrameDisplayer::Put(), and put(). |
|
||||||||||||||||||||||||
|
Reformat.
Definition at line 356 of file displayer.cc. References DISPLAY_BGR, DISPLAY_BGR0, DISPLAY_RGB, DISPLAY_RGB16, DISPLAY_YUV, preferredHeight(), Reformat222(), Reformat323(), Reformat324(), and Reformat424(). Referenced by put(). 00358 {
00359 //struct timeval tv;
00360 //gettimeofday(&tv, NULL);
00361 //long long starttime = tv.tv_sec * 1000000 + tv.tv_usec;
00362
00363 unsigned char * img = ( unsigned char * ) image;
00364 if ( inFormat == DISPLAY_YUV && outFormat == DISPLAY_YUV )
00365 Reformat424( img, width, height, this->preferredWidth(), this->preferredHeight() );
00366 else if ( inFormat == DISPLAY_RGB16 && outFormat == DISPLAY_RGB16 )
00367 Reformat222( img, width, height, this->preferredWidth(), this->preferredHeight() );
00368 else if ( inFormat == DISPLAY_BGR && outFormat == DISPLAY_RGB )
00369 Reformat323( img, width, height, this->preferredWidth(), this->preferredHeight() );
00370 else if ( inFormat == DISPLAY_BGR && outFormat == DISPLAY_BGR0 )
00371 Reformat324( img, width, height, this->preferredWidth(), this->preferredHeight() );
00372 // Incorrect, but covers the most correctly [take care when introducing new formats]
00373 else if ( inFormat == outFormat )
00374 Reformat323( img, width, height, this->preferredWidth(), this->preferredHeight() );
00375
00376 //gettimeofday(&tv, NULL);
00377 //long long endtime = tv.tv_sec * 1000000 + tv.tv_usec;
00378 //cerr << "Reformatting took " << endtime - starttime << endl;
00379 }
|
|
||||||||||||||||||||||||
|
Definition at line 227 of file displayer.cc. References pixels. Referenced by reformat(). 00228 {
00229 // Fixed value for rounding to the middle pixel (instead of defaulting to top left)
00230 int rounding = 1 << 15;
00231 // xfactor and yfactor represent the granularity of the output, relative to the input
00232 unsigned int xfactor = ( inWidth << 16 ) / outWidth;
00233 unsigned int yfactor = ( inHeight << 16 ) / outHeight;
00234 // multiplication of x and yfactors to the output height
00235 unsigned int ymax = yfactor * outHeight;
00236 unsigned int xmax = xfactor * outWidth;
00237 // y is used to point to the start of each line in the input
00238 unsigned int y = 0;
00239 // i is a temporary variable used in iterating through each line
00240 unsigned int i = 0;
00241 // o is the position in the output
00242 unsigned int o = 0;
00243
00244 for ( unsigned int yft = 0; yft < ymax; yft += yfactor )
00245 {
00246 y = ( ( yft + rounding ) >> 16 ) * inWidth * 2;
00247 for ( unsigned int xft = 0; xft < xmax; xft += xfactor )
00248 {
00249 i = y + ( ( xft + rounding ) >> 16 ) * 2;
00250 pixels[ o ++ ] = image[ i ++ ];
00251 pixels[ o ++ ] = image[ i ];
00252 }
00253 }
00254 }
|
|
||||||||||||||||||||||||
|
Definition at line 256 of file displayer.cc. References pixels. Referenced by reformat(). 00257 {
00258 // Fixed value for rounding to the middle pixel (instead of defaulting to top left)
00259 int rounding = 1 << 15;
00260 // xfactor and yfactor represent the granularity of the output, relative to the input
00261 unsigned int xfactor = ( inWidth << 16 ) / outWidth;
00262 unsigned int yfactor = ( inHeight << 16 ) / outHeight;
00263 // multiplication of x and yfactors to the output height
00264 unsigned int ymax = yfactor * outHeight;
00265 unsigned int xmax = xfactor * outWidth;
00266 // y is used to point to the start of each line in the input
00267 unsigned int y = 0;
00268 // i is a temporary variable used in iterating through each line
00269 unsigned int i = 0;
00270 // o is the position in the output
00271 unsigned int o = 0;
00272
00273 for ( unsigned int yft = 0; yft < ymax; yft += yfactor )
00274 {
00275 y = ( ( yft + rounding ) >> 16 ) * inWidth * 3;
00276 for ( unsigned int xft = 0; xft < xmax; xft += xfactor )
00277 {
00278 i = y + ( ( xft + rounding ) >> 16 ) * 3;
00279 pixels[ o ++ ] = image[ i ++ ];
00280 pixels[ o ++ ] = image[ i ++ ];
00281 pixels[ o ++ ] = image[ i ];
00282 }
00283 }
00284 }
|
|
||||||||||||||||||||||||
|
Definition at line 286 of file displayer.cc. References pixels. 00287 {
00288 // Fixed value for rounding to the middle pixel (instead of defaulting to top left)
00289 int rounding = 1 << 15;
00290 // xfactor and yfactor represent the granularity of the output, relative to the input
00291 unsigned int xfactor = ( inWidth << 16 ) / outWidth;
00292 unsigned int yfactor = ( inHeight << 16 ) / outHeight;
00293 // multiplication of x and yfactors to the output height
00294 unsigned int ymax = yfactor * outHeight;
00295 unsigned int xmax = xfactor * outWidth;
00296 // y is used to point to the start of each line in the input
00297 unsigned int y = 0;
00298 // i is a temporary variable used in iterating through each line
00299 unsigned int i = 0;
00300 // o is the position in the output
00301 unsigned int o = 0;
00302
00303 for ( unsigned int yft = 0; yft < ymax; yft += yfactor )
00304 {
00305 y = ( ( yft + rounding ) >> 16 ) * inWidth * 3;
00306 for ( unsigned int xft = 0; xft < xmax; xft += xfactor )
00307 {
00308 i = y + ( ( xft + rounding ) >> 16 ) * 3 + 2;
00309 pixels[ o ++ ] = image[ i ];
00310 pixels[ o ++ ] = image[ -- i ];
00311 pixels[ o ++ ] = image[ -- i ];
00312 }
00313 }
00314 }
|
|
||||||||||||||||||||||||
|
Definition at line 316 of file displayer.cc. References pixels. Referenced by reformat(). 00317 {
00318 // Fixed value for rounding to the middle pixel (instead of defaulting to top left)
00319 int rounding = 1 << 15;
00320 // xfactor and yfactor represent the granularity of the output, relative to the input
00321 unsigned int xfactor = ( inWidth << 16 ) / outWidth;
00322 unsigned int yfactor = ( inHeight << 16 ) / outHeight;
00323 // multiplication of x and yfactors to the output height
00324 unsigned int ymax = yfactor * outHeight;
00325 unsigned int xmax = xfactor * outWidth;
00326 // y is used to point to the start of each line in the input
00327 unsigned int y = 0;
00328 // i is a temporary variable used in iterating through each line
00329 unsigned int i = 0;
00330 // o is the position in the output
00331 unsigned int o = 0;
00332
00333 for ( unsigned int yft = 0; yft < ymax; yft += yfactor )
00334 {
00335 y = ( ( yft + rounding ) >> 16 ) * inWidth * 3;
00336 for ( unsigned int xft = 0; xft < xmax; xft += xfactor )
00337 {
00338 i = y + ( ( xft + rounding ) >> 16 ) * 3;
00339 pixels[ o ++ ] = image[ i ++ ];
00340 pixels[ o ++ ] = image[ i ++ ];
00341 pixels[ o ++ ] = image[ i ];
00342 pixels[ o ++ ] = 0;
00343 }
00344 }
00345 }
|
|
||||||||||||||||||||||||
|
Definition at line 196 of file displayer.cc. References pixels. Referenced by reformat(). 00197 {
00198 // Fixed value for rounding to the middle pixel (instead of defaulting to top left)
00199 int rounding = 1 << 15;
00200 // xfactor and yfactor represent the granularity of the output, relative to the input
00201 unsigned int xfactor = ( inWidth << 16 ) / outWidth;
00202 unsigned int yfactor = ( inHeight << 16 ) / outHeight;
00203 // multiplication of x and yfactors to the output height
00204 unsigned int ymax = yfactor * outHeight;
00205 unsigned int xmax = xfactor * outWidth;
00206 // y is used to point to the start of each line in the input
00207 unsigned int y = 0;
00208 // i is a temporary variable used in iterating through each line
00209 unsigned int i = 0;
00210 // o is the position in the output
00211 unsigned int o = 0;
00212
00213 for ( unsigned int yft = 0; yft < ymax; yft += yfactor )
00214 {
00215 y = ( ( yft + rounding ) >> 16 ) * inWidth * 4;
00216 for ( unsigned int xft = 0; xft < xmax; xft += xfactor )
00217 {
00218 i = y + ( ( xft + rounding ) >> 16 ) * 4;
00219 pixels[ o ++ ] = image[ i ++ ];
00220 pixels[ o ++ ] = image[ i ++ ];
00221 pixels[ o ++ ] = image[ i ++ ];
00222 pixels[ o ++ ] = image[ i ];
00223 }
00224 }
00225 }
|
|
|
Indicates if an object can be used to render images on the running system.
Reimplemented in XDisplayer, XvDisplayer, and GdkDisplayer. Definition at line 121 of file displayer.cc. Referenced by FindDisplayer::getDisplayer(). 00122 {
00123 return false;
00124 }
|
|
|
Definition at line 108 of file displayer.h. Referenced by GdkDisplayer::GdkDisplayer(), preferredHeight(), GdkDisplayer::put(), and XvDisplayer::XvDisplayer(). |
|
|
Definition at line 107 of file displayer.h. Referenced by GdkDisplayer::GdkDisplayer(), preferredWidth(), and XvDisplayer::XvDisplayer(). |
|
|
Definition at line 123 of file displayer.h. Referenced by put(), Reformat222(), Reformat323(), Reformat323R(), Reformat324(), and Reformat424(). |
1.4.2