Changeset 3170 for libpipi


Ignore:
Timestamp:
Oct 31, 2008, 10:02:15 PM (11 years ago)
Author:
nico
Message:
  • Centralize pipi's errors managment in macro RETURN_SUCCESS
  • Change php headers in samples programs
  • Add binding for pipi_draw_line
  • Check args in pipi_new_histogram and pipi_get_version
Location:
libpipi/trunk/pipi-php
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • libpipi/trunk/pipi-php/examples/example1.php

    r3090 r3170  
    1 <?
     1#!/usr/bin/php5
     2<?php
     3
    24$img = pipi_load_stock("random:128x128");
    35$img = pipi_gaussian_blur($img, 10);
     
    68$img = pipi_tile($img, 256, 256);
    79pipi_save($img, "out.png");
     10
     11?>
  • libpipi/trunk/pipi-php/examples/histogram.php

    r3086 r3170  
    1 <?
     1#!/usr/bin/php5
     2<?php
     3
    24$img = pipi_load_stock("random:128x128");
    35$img = pipi_gaussian_blur($img, 10);
     
    1012
    1113pipi_save($histogram_img, "out.png");
     14
     15?>
  • libpipi/trunk/pipi-php/examples/pipi.php

    r3087 r3170  
    11#!/usr/bin/php5
    2 <?
     2<?php
    33$aliases = array(
    44        "-o" => "--save",
     
    4747        }
    4848}
     49
     50?>
  • libpipi/trunk/pipi-php/php_pipi.c

    r3164 r3170  
    194194        ZEND_FETCH_RESOURCE(img2, pipi_image_t*, &_zval2, -1, PHP_PIPI_IMAGE_RES_NAME, le_pipi_image);
    195195
     196#define RETURN_SUCCESS(i) \
     197        RETURN_BOOL((i) == 0);
    196198
    197199
     
    202204
    203205PHP_FUNCTION(pipi_get_version) {
     206        if (ZEND_NUM_ARGS() != 0) {
     207                WRONG_PARAM_COUNT;
     208        }
    204209        RETURN_STRING(estrdup(pipi_get_version()), 0);
    205210}
     
    232237
    233238        if (arg2_len != 0) {
    234                 RETURN_BOOL(pipi_command(ctxt, arg1, arg2) == 0);
    235         }
    236         RETURN_BOOL(pipi_command(ctxt, arg1) == 0);     
     239                RETURN_SUCCESS(pipi_command(ctxt, arg1, arg2));
     240        }
     241        RETURN_SUCCESS(pipi_command(ctxt, arg1));       
    237242}
    238243
     
    281286        ZEND_FETCH_RESOURCE(img, pipi_image_t*, &res, -1, PHP_PIPI_IMAGE_RES_NAME, le_pipi_image);
    282287
    283         RETURN_BOOL(pipi_save(img, str) == 0); 
     288        RETURN_SUCCESS(pipi_save(img, str));   
    284289}
    285290
     
    691696
    692697PHP_FUNCTION(pipi_draw_line) {
     698        zval *_zval;
     699        long x1, y1, x2, y2, color, style = 0;
     700        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlllll|l", &_zval, &x1, &y1, &x2, &y2, &color, &style) == FAILURE) {
     701                RETURN_FALSE;
     702        }
     703        pipi_image_t *img;
     704        ZEND_FETCH_RESOURCE(img, pipi_image_t*, &_zval, -1, PHP_PIPI_IMAGE_RES_NAME, le_pipi_image);
     705        RETURN_SUCCESS(pipi_draw_line(img, x1, y1, x2, y2, color, style));
    693706}
    694707
     
    767780
    768781PHP_FUNCTION(pipi_new_histogram) {
     782        if (ZEND_NUM_ARGS() != 0) {
     783                WRONG_PARAM_COUNT;
     784        }
    769785        pipi_histogram_t *histogram;
    770786        histogram = pipi_new_histogram();
     
    783799        ZEND_FETCH_RESOURCE(histogram, pipi_histogram_t*, &_zval_hst, -1, PHP_PIPI_HISTOGRAM_RES_NAME, le_pipi_histogram);
    784800
    785         RETURN_BOOL(pipi_get_image_histogram(image, histogram, flags) == 0);
     801        RETURN_SUCCESS(pipi_get_image_histogram(image, histogram, flags));
    786802}
    787803
     
    797813        ZEND_FETCH_RESOURCE(histogram, pipi_histogram_t*, &_zval_hst, -1, PHP_PIPI_HISTOGRAM_RES_NAME, le_pipi_histogram);
    798814
    799         RETURN_BOOL(pipi_render_histogram(image, histogram, flags) == 0);
    800 }
    801 
    802 
     815        RETURN_SUCCESS(pipi_render_histogram(image, histogram, flags));
     816}
     817
     818
Note: See TracChangeset for help on using the changeset viewer.