Changeset 407
- Timestamp:
- Jan 4, 2005, 11:30:52 AM (18 years ago)
- Location:
- pwntcha/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
pwntcha/trunk/configure.ac
r406 r407 20 20 21 21 AC_CHECK_FUNCS(getopt_long) 22 23 # Use SDL? 24 ac_cv_my_have_sdl="no" 25 save_CPPFLAGS="${CPPFLAGS}" 26 AC_PATH_PROG(SDL_CONFIG, sdl-config, no) 27 if test "${SDL_CONFIG}" != "no"; then 28 CPPFLAGS="${CPPFLAGS} `sdl-config --cflags`" 29 fi 30 AC_CHECK_HEADERS(SDL_image.h, 31 [ac_cv_my_have_sdl="yes"], 32 [ac_cv_my_have_sdl="no"]) 33 CPPFLAGS="${save_CPPFLAGS}" 34 AM_CONDITIONAL(USE_SDL, test "${ac_cv_my_have_sdl}" = "yes") 22 35 23 36 # Use OpenCV? … … 47 60 AM_CONDITIONAL(USE_IMLIB2, test "${ac_cv_my_have_imlib2}" = "yes") 48 61 49 if test "${ac_cv_my_have_ imlib2}" = "no" -a "${ac_cv_my_have_opencv}" = "no"; then50 AC_MSG_ERROR([[cannot find Imlib2 or OpenCV, please install one of them]])62 if test "${ac_cv_my_have_sdl}" = "yes" -a "${ac_cv_my_have_imlib2}" = "no" -a "${ac_cv_my_have_opencv}" = "no"; then 63 AC_MSG_ERROR([[cannot find SDL_Image, Imlib2 or OpenCV, please install one of them]]) 51 64 fi 52 65 -
pwntcha/trunk/src/Makefile.am
r400 r407 14 14 test.c 15 15 16 if USE_ OPENCV17 ADDITIONAL_CFLAGS = ` opencv-config --cflags`18 ADDITIONAL_LDFLAGS = ` opencv-config --libs opencv highgui`16 if USE_SDL 17 ADDITIONAL_CFLAGS = `sdl-config --cflags` 18 ADDITIONAL_LDFLAGS = `sdl-config --libs` -lSDL_image 19 19 else 20 20 if USE_IMLIB2 … … 22 22 ADDITIONAL_LDFLAGS = `imlib2-config --libs` 23 23 else 24 if USE_OPENCV 25 ADDITIONAL_CFLAGS = `opencv-config --cflags` 26 ADDITIONAL_LDFLAGS = `opencv-config --libs opencv highgui` 27 else 24 28 ADDITIONAL_CFLAGS = 25 29 ADDITIONAL_LDFLAGS = 26 30 endif 27 31 endif 32 endif 28 33 -
pwntcha/trunk/src/image.c
r389 r407 16 16 #include "common.h" 17 17 18 #if defined(HAVE_CV_H) 18 #if defined(HAVE_SDL_IMAGE_H) 19 # include <SDL_image.h> 20 #elif defined(HAVE_IMLIB2_H) 21 # include <Imlib2.h> 22 #elif defined(HAVE_CV_H) 19 23 # include <cv.h> 20 24 # include <highgui.h> 21 #elif defined(HAVE_IMLIB2_H)22 # include <Imlib2.h>23 25 #else 24 26 # error "No imaging library" … … 28 30 { 29 31 struct image *img; 30 #if defined(HAVE_CV_H) 32 #if defined(HAVE_SDL_IMAGE_H) 33 SDL_Surface *priv = IMG_Load(name); 34 #elif defined(HAVE_IMLIB2_H) 35 Imlib_Image priv = imlib_load_image(name); 36 #elif defined(HAVE_CV_H) 31 37 IplImage *priv = cvLoadImage(name, -1); 32 #elif defined(HAVE_IMLIB2_H)33 Imlib_Image priv = imlib_load_image(name);34 38 #endif 35 39 … … 38 42 39 43 img = malloc(sizeof(struct image)); 40 #if defined(HAVE_ CV_H)41 img->width = priv->w idth;42 img->height = priv->h eight;43 img->pitch = priv-> widthStep;44 img->channels = priv-> nChannels;45 img->pixels = priv-> imageData;44 #if defined(HAVE_SDL_IMAGE_H) 45 img->width = priv->w; 46 img->height = priv->h; 47 img->pitch = priv->pitch; 48 img->channels = priv->format->BytesPerPixel; 49 img->pixels = priv->pixels; 46 50 #elif defined(HAVE_IMLIB2_H) 47 51 imlib_context_set_image(priv); … … 51 55 img->channels = 4; 52 56 img->pixels = (char *)imlib_image_get_data(); 53 #endif 54 img->priv = (void *)priv; 55 56 return img; 57 } 58 59 struct image *image_new(int width, int height) 60 { 61 struct image *img; 62 #if defined(HAVE_CV_H) 63 IplImage *priv = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 3); 64 #elif defined(HAVE_IMLIB2_H) 65 Imlib_Image priv = imlib_create_image(width, height); 66 #endif 67 68 if(!priv) 69 return NULL; 70 71 img = malloc(sizeof(struct image)); 72 #if defined(HAVE_CV_H) 57 #elif defined(HAVE_CV_H) 73 58 img->width = priv->width; 74 59 img->height = priv->height; … … 76 61 img->channels = priv->nChannels; 77 62 img->pixels = priv->imageData; 63 #endif 64 img->priv = (void *)priv; 65 66 return img; 67 } 68 69 struct image *image_new(int width, int height) 70 { 71 struct image *img; 72 #if defined(HAVE_SDL_IMAGE_H) 73 SDL_Surface *priv; 74 Uint32 rmask, gmask, bmask, amask; 75 # if SDL_BYTEORDER == SDL_BIG_ENDIAN 76 rmask = 0xff000000; 77 gmask = 0x00ff0000; 78 bmask = 0x0000ff00; 79 amask = 0x000000ff; 80 # else 81 rmask = 0x000000ff; 82 gmask = 0x0000ff00; 83 bmask = 0x00ff0000; 84 amask = 0xff000000; 85 # endif 86 priv = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32, 87 rmask, gmask, bmask, amask); 88 #elif defined(HAVE_IMLIB2_H) 89 Imlib_Image priv = imlib_create_image(width, height); 90 #elif defined(HAVE_CV_H) 91 IplImage *priv = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 3); 92 #endif 93 94 if(!priv) 95 return NULL; 96 97 img = malloc(sizeof(struct image)); 98 #if defined(HAVE_SDL_IMAGE_H) 99 img->width = priv->w; 100 img->height = priv->h; 101 img->pitch = priv->pitch; 102 img->channels = priv->format->BytesPerPixel; 103 img->pixels = priv->pixels; 78 104 #elif defined(HAVE_IMLIB2_H) 79 105 imlib_context_set_image(priv); … … 83 109 img->channels = 4; 84 110 img->pixels = (char *)imlib_image_get_data(); 111 #elif defined(HAVE_CV_H) 112 img->width = priv->width; 113 img->height = priv->height; 114 img->pitch = priv->widthStep; 115 img->channels = priv->nChannels; 116 img->pixels = priv->imageData; 85 117 #endif 86 118 img->priv = (void *)priv; … … 91 123 void image_free(struct image *img) 92 124 { 93 #if defined(HAVE_CV_H) 125 #if defined(HAVE_SDL_IMAGE_H) 126 SDL_FreeSurface(img->priv); 127 #elif defined(HAVE_IMLIB2_H) 128 imlib_context_set_image(img->priv); 129 imlib_free_image(); 130 #elif defined(HAVE_CV_H) 94 131 IplImage *iplimg; 95 132 iplimg = (IplImage *)img->priv; 96 133 cvReleaseImage(&iplimg); 97 #elif defined(HAVE_IMLIB2_H)98 imlib_context_set_image(img->priv);99 imlib_free_image();100 134 #endif 101 135 … … 147 181 void image_display(struct image *img) 148 182 { 149 #if defined(HAVE_CV_H) 183 #if defined(HAVE_SDL_IMAGE_H) 184 //Nothing to do here 185 #elif defined(HAVE_IMLIB2_H) 186 //char name[BUFSIZ]; 187 //static int i = 0; 188 //sprintf(name, "image%i-%ix%i.png", i++, img->width, img->height); 189 //imlib_context_set_image(img->priv); 190 //imlib_save_image(name); 191 //fprintf(stderr, "saved to %s\n", name); 192 #elif defined(HAVE_CV_H) 150 193 char name[BUFSIZ]; 151 194 sprintf(name, "Image %p (%i x %i)", img, img->width, img->height); … … 155 198 while((unsigned char)cvWaitKey(0) != 0x1b) 156 199 ; 157 #elif defined(HAVE_IMLIB2_H) 158 //char name[BUFSIZ]; 159 //static int i = 0; 160 //sprintf(name, "image%i-%ix%i.png", i++, img->width, img->height); 161 //imlib_context_set_image(img->priv); 162 //imlib_save_image(name); 163 //fprintf(stderr, "saved to %s\n", name); 164 #endif 165 } 166 200 #endif 201 } 202
Note: See TracChangeset
for help on using the changeset viewer.