00001 /* --------------------------------------------------------------------------- 00002 Phission : 00003 Realtime Vision Processing System 00004 00005 Copyright (C) 2003-2006 Philip D.S. Thoren (pthoren@cs.uml.edu) 00006 University of Massachusetts at Lowell, 00007 Laboratory for Artificial Intelligence and Robotics 00008 00009 This file is part of Phission. 00010 00011 Phission is free software; you can redistribute it and/or modify 00012 it under the terms of the GNU Lesser General Public License as published by 00013 the Free Software Foundation; either version 2 of the License, or 00014 (at your option) any later version. 00015 00016 Phission is distributed in the hope that it will be useful, 00017 but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 GNU Lesser General Public License for more details. 00020 00021 You should have received a copy of the GNU Lesser General Public License 00022 along with Phission; if not, write to the Free Software 00023 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00024 00025 ---------------------------------------------------------------------------*/ 00026 #ifndef _IMAGEGFX_H 00027 #define _IMAGEGFX_H 00028 00029 #include <phStandard.h> 00030 #include <phStdint.h> 00031 #include <ImageDefinitions.h> 00032 00033 #ifdef __cplusplus 00034 extern "C" 00035 { 00036 #endif 00037 00038 /* ---------------------------------------------------------------------- */ 00048 /* ------------------------------------------------------------------------ */ 00052 typedef struct phImageSurface_t 00053 { 00054 /* The width of the image surface */ 00055 uint32_t w; 00056 /* The height of the image surface */ 00057 uint32_t h; 00058 /* The format of the image surface */ 00059 uint32_t f; 00060 /* The depth of each pixel in the image surface */ 00061 uint32_t d; 00062 /* The pointer to the image surface pixels */ 00063 uint8_t *p; 00064 } phImageSurface; 00065 00066 /* ---------------------------------------------------------------------- */ 00070 typedef struct phUSize_t 00071 { 00072 uint32_t w; 00073 uint32_t h; 00074 } phUSize; 00075 00076 /* ---------------------------------------------------------------------- */ 00080 typedef struct phUPoint_t 00081 { 00082 uint32_t x; 00083 uint32_t y; 00084 } phUPoint; 00085 00086 /* ---------------------------------------------------------------------- */ 00090 typedef struct phSize_t 00091 { 00092 /* The width value */ 00093 int32_t w; 00094 /* The height value */ 00095 int32_t h; 00096 } phSize; 00097 00098 /* ---------------------------------------------------------------------- */ 00102 typedef struct phPoint_t 00103 { 00104 /* The x coord */ 00105 int32_t x; 00106 /* The y coord */ 00107 int32_t y; 00108 } phPoint; 00109 00110 /* ---------------------------------------------------------------------- */ 00114 typedef struct phLine_t 00115 { 00116 /* The x coord for the start of the line */ 00117 int32_t x1; 00118 /* The y */ 00119 int32_t y1; 00120 /* The x coord for the end of the line */ 00121 int32_t x2; 00122 /* The y */ 00123 int32_t y2; 00124 } phLine; 00125 00126 /* ---------------------------------------------------------------------- */ 00130 typedef struct phCircle_t 00131 { 00132 /* The x coord of the center of the circle */ 00133 int32_t x; 00134 /* The y */ 00135 int32_t y; 00136 /* The radius of the circle */ 00137 int32_t r; 00138 } phCircle; 00139 00140 /* ---------------------------------------------------------------------- */ 00144 typedef struct phRectangle_t 00145 { 00146 /* The x coord for the top left of the rectangle */ 00147 int32_t x; 00148 /* The y */ 00149 int32_t y; 00150 /* The width of the rectangle */ 00151 int32_t w; 00152 /* The height of the rectangle */ 00153 int32_t h; 00154 } phRectangle; 00155 00156 /* ---------------------------------------------------------------------- */ 00160 typedef struct phTriangle_t 00161 { 00162 /* The x coord for the start of the first edge of the triangle */ 00163 int32_t x1; 00164 /* The y */ 00165 int32_t y1; 00166 /* The x coord for the start of the second edge of the triangle */ 00167 int32_t x2; 00168 /* The y */ 00169 int32_t y2; 00170 /* The x coord for the start of the third edge of the triangle */ 00171 int32_t x3; 00172 /* The y */ 00173 int32_t y3; 00174 } phTriangle; 00175 00176 /* ---------------------------------------------------------------------- */ 00180 typedef struct phCross_t 00181 { 00182 /* The center x coord of the cross */ 00183 int32_t x; 00184 /* The center y */ 00185 int32_t y; 00186 /* The x size; The length of the horizontal branches from the center */ 00187 int32_t xs; 00188 /* The y size; The length of the vertical branches from the center */ 00189 int32_t ys; 00190 } phCross; 00191 00192 #define phDrawingHollow (0) 00193 #define phDrawingNoFill (0) 00194 #define phDrawingFill (1) 00195 00196 /* ---------------------------------------------------------------------- */ 00197 /* TODO: 00198 * 00199 * Transparency Support: 00200 * ph_draw_horizline [X] 00201 * ph_draw_vertline [X] 00202 * ph_drawline_bresenham [X] 00203 * ph_drawcircle_midpoint [X] 00204 * ph_draw_hollow_rect [X] 00205 * ph_draw_hollow_triangle [X] 00206 * ph_triangle_fill [X] 00207 * 00208 * Size Support: 00209 * ph_draw_horizline [ ] 00210 * ph_draw_vertline [ ] 00211 * ph_drawline_bresenham [ ] 00212 * ph_drawcircle_midpoint [ ] 00213 * ph_draw_hollow_rect [ ] 00214 * ph_draw_hollow_triangle [ ] 00215 * ph_triangle_fill [ ] 00216 * 00217 */ 00218 /* ---------------------------------------------------------------------- */ 00219 PHAPI(void) ph_draw_horizline( phImageSurface *s, 00220 phColor c, 00221 uint8_t transparency, 00222 int32_t x1, 00223 int32_t x2, 00224 int32_t y ); 00225 00226 PHAPI(void) ph_draw_vertline( phImageSurface *s, 00227 phColor c, 00228 uint8_t transparency, 00229 int32_t y1, 00230 int32_t y2, 00231 int32_t x ); 00232 00248 PHAPI(void) ph_drawline_bresenham( phImageSurface *s, 00249 phColor c, 00250 uint8_t transparency, 00251 int32_t x1, 00252 int32_t y1, 00253 int32_t x2, 00254 int32_t y2 ); 00255 00256 /* ---------------------------------------------------------------------- */ 00257 PHAPI(void) ph_drawcircle_midpoint( phImageSurface *s, 00258 phColor color, 00259 uint8_t transparency, 00260 int32_t x0, 00261 int32_t y0, 00262 int32_t radius ); 00263 00264 /* ---------------------------------------------------------------------- */ 00280 PHAPI(void) ph_draw_hollow_rect( phImageSurface *s, 00281 phColor c, 00282 uint8_t transparency, 00283 uint32_t x1, 00284 uint32_t y1, 00285 uint32_t x2, 00286 uint32_t y2 ); 00287 00288 /* ---------------------------------------------------------------------- */ 00289 PHAPI(void) ph_draw_hollow_triangle(phImageSurface *s, 00290 phColor c, 00291 uint8_t transparency, 00292 uint32_t x1, 00293 uint32_t y1, 00294 uint32_t x2, 00295 uint32_t y2, 00296 uint32_t x3, 00297 uint32_t y3 ); 00298 00299 /* ---------------------------------------------------------------------- */ 00300 PHAPI(void) ph_triangle_fill(phImageSurface *s, 00301 phColor c, 00302 uint8_t transparency, 00303 int32_t x1, 00304 int32_t y1, 00305 int32_t x2, 00306 int32_t y2, 00307 int32_t x3, 00308 int32_t y3 ); 00309 00310 /* ---------------------------------------------------------------------- */ 00319 PHAPI(phImageSurface) phImageSurface_new( uint32_t w, 00320 uint32_t h, 00321 uint32_t f, 00322 uint8_t *p ); 00329 PHAPI(phSize) phSize_new ( int32_t w, int32_t h ); 00336 PHAPI(phPoint) phPoint_new ( int32_t x, int32_t y ); 00345 PHAPI(phLine) phLine_new ( int32_t x1, int32_t y1, 00346 int32_t x2, int32_t y2 ); 00354 PHAPI(phCircle) phCircle_new ( int32_t x, int32_t y, int32_t r ); 00363 PHAPI(phRectangle) phRectangle_new ( int32_t x, int32_t y, 00364 int32_t w, int32_t h ); 00375 PHAPI(phTriangle) phTriangle_new ( int32_t x1, int32_t y1, 00376 int32_t x2, int32_t y2, 00377 int32_t x3, int32_t y3 ); 00388 PHAPI(phCross) phCross_new ( int32_t x, int32_t y, 00389 int32_t xs, int32_t ys ); 00390 00391 /* ------------------------------------------------------------------------- */ 00392 /* 00393 int phLine_to_phPoint ( phLine l, phPoint *array ); 00394 int phCircle_to_phPoint ( phCircle c, phPoint *array ); 00395 int phRectangle_to_phPoint ( phRectangle r, phPoint *array ); 00396 int phTriangle_to_phPoint ( phTriangle t, phPoint *array ); 00397 int phCross_to_phPoint ( phCross x, phPoint *array ); 00398 */ 00399 00400 /* ------------------------------------------------------------------------- */ 00414 PHAPI(void) ph_draw_point ( phImageSurface *s, 00415 phPoint p, 00416 phColor color, 00417 uint8_t size, 00418 uint8_t transparency ); 00432 PHAPI(void) ph_draw_line ( phImageSurface *s, 00433 phLine l, 00434 phColor color, 00435 uint8_t size, 00436 uint8_t transparency ); 00450 PHAPI(void) ph_draw_circle ( phImageSurface *s, 00451 phCircle c, 00452 phColor color, 00453 uint8_t size, 00454 uint8_t fill, 00455 uint8_t transparency ); 00469 PHAPI(void) ph_draw_rectangle ( phImageSurface *s, 00470 phRectangle r, 00471 phColor color, 00472 uint8_t size, 00473 uint8_t fill, 00474 uint8_t transparency ); 00491 PHAPI(void) ph_draw_triangle ( phImageSurface *s, 00492 phTriangle t, 00493 phColor color, 00494 uint8_t size, 00495 uint8_t fill, 00496 uint8_t transparency ); 00510 PHAPI(void) ph_draw_cross ( phImageSurface *s, 00511 phCross x, 00512 phColor color, 00513 uint8_t size, 00514 uint8_t transparency ); 00515 00516 /* ---------------------------------------------------------------------- */ 00517 PHAPI(int) phPoint_print ( int fd, phPoint p ); 00518 PHAPI(int) phLine_print ( int fd, phLine l ); 00519 PHAPI(int) phCircle_print ( int fd, phCircle c ); 00520 PHAPI(int) phRectangle_print ( int fd, phRectangle r ); 00521 PHAPI(int) phTriangle_print ( int fd, phTriangle t ); 00522 PHAPI(int) phCross_print ( int fd, phCross c ); 00523 00524 /* ---------------------------------------------------------------------- */ 00541 typedef struct phDrawing_t *phDrawing; 00542 00543 /* ---------------------------------------------------------------------- */ 00548 PHAPI(int) phDrawing_alloc( phDrawing *d ); 00553 PHAPI(void) phDrawing_free( phDrawing *d ); 00554 00555 /* ---------------------------------------------------------------------- */ 00559 PHAPI(int) phDrawing_copy( phDrawing d, 00560 phDrawing copy ); 00561 00562 /* ---------------------------------------------------------------------- */ 00567 PHAPI(void) phDrawing_draw( phDrawing d, 00568 phImageSurface *s ); 00569 00570 /* ---------------------------------------------------------------------- */ 00574 PHAPI(void) phDrawing_clear ( phDrawing d ); 00578 PHAPI(void) phDrawing_clearPoints ( phDrawing d ); 00582 PHAPI(void) phDrawing_clearLines ( phDrawing d ); 00586 PHAPI(void) phDrawing_clearCircles ( phDrawing d ); 00590 PHAPI(void) phDrawing_clearRectangles ( phDrawing d ); 00594 PHAPI(void) phDrawing_clearTriangles ( phDrawing d ); 00598 PHAPI(void) phDrawing_clearCrosses ( phDrawing d ); 00599 00600 /* --------------------------------------------------------------------- */ 00608 PHAPI(int) phDrawing_addPoint ( phDrawing d, 00609 phPoint p, 00610 phColor color, 00611 uint8_t size, 00612 uint8_t transparency ); 00620 PHAPI(int) phDrawing_addLine ( phDrawing d, 00621 phLine l, 00622 phColor color, 00623 uint8_t size, 00624 uint8_t transparency ); 00632 PHAPI(int) phDrawing_addCircle ( phDrawing d, 00633 phCircle c, 00634 phColor color, 00635 uint8_t size, 00636 uint8_t fill, 00637 uint8_t transparency ); 00645 PHAPI(int) phDrawing_addRectangle ( phDrawing d, 00646 phRectangle r, 00647 phColor color, 00648 uint8_t size, 00649 uint8_t fill, 00650 uint8_t transparency ); 00658 PHAPI(int) phDrawing_addTriangle ( phDrawing d, 00659 phTriangle t, 00660 phColor color, 00661 uint8_t size, 00662 uint8_t fill, 00663 uint8_t transparency ); 00671 PHAPI(int) phDrawing_addCross ( phDrawing d, 00672 phCross x, 00673 phColor color, 00674 uint8_t size, 00675 uint8_t transparency ); 00676 00677 /* ---------------------------------------------------------------------- */ /* end \addtogroup Image_Graphics */ /* end \addtogroup Image */ 00686 00687 #ifdef __cplusplus 00688 } 00689 #endif 00690 00691 #endif /* _IMAGEGFX_H */
Copyright (C) 2002 - 2007 |
Philip D.S. Thoren ( pthoren@users.sourceforge.net ) University Of Massachusetts at Lowell Robotics Lab |