Changeset 3122 for libcaca/trunk/caca-php/php_caca.c
- Timestamp:
- Oct 27, 2008, 8:14:32 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/caca-php/php_caca.c
r3121 r3122 344 344 RETURN_BOOL((i) == 0); 345 345 346 //------- Function that allows to fetch external php resources such as gd resouces 346 //---------- Some usefull functions --------------------// 347 348 //Fetch external php resources such as gd resouces 347 349 348 350 void *fetch_external_resource(zval *_zval, char const *type_name) { … … 350 352 int resource_type; 351 353 void *result = zend_list_find(resource_id, &resource_type); 354 if (!result) 355 return NULL; 352 356 char *resource_type_name = zend_rsrc_list_get_rsrc_type(resource_id); 353 357 return (strcmp(resource_type_name, type_name) == 0) ? result : NULL; 354 358 } 359 360 //Fetch buffer of pixels from gdImage 361 362 void *gd_get_pixels(gdImage *img) { 363 if (img->trueColor) { 364 int line_size = img->sx * sizeof(int); 365 void *result = malloc(img->sy * line_size); 366 int j; 367 for (j = 0; j < img->sy; j++) 368 memcpy(result + (j * line_size), (const void *) img->tpixels[j], line_size); 369 return result; 370 } 371 return NULL; 372 } 373 374 355 375 356 376 //------- PHP Binding's specific functions ----------// … … 1163 1183 } 1164 1184 1165 printf("image size: %i x %i\n", img->sx, img->sy); 1166 if (img->trueColor) { 1167 printf("image is true color\n"); 1168 RETURN_SUCCESS(caca_dither_bitmap(canvas, x, y, w, h, dither, (void *) *(img->tpixels))); 1169 } 1185 void *pixels = gd_get_pixels(img); 1186 if (!pixels) { 1187 RETURN_FALSE; 1188 } 1189 1190 caca_dither_bitmap(canvas, x, y, w, h, dither, pixels); 1191 free(pixels); 1192 RETURN_TRUE; 1170 1193 } 1171 1194
Note: See TracChangeset
for help on using the changeset viewer.