imagecolourstotal_basic.phpt 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. --TEST--
  2. Test imagecolorstotal() function : basic functionality
  3. --CREDITS--
  4. Felix De Vliegher <felix.devliegher@gmail.com>
  5. --SKIPIF--
  6. <?php
  7. if (!extension_loaded('gd')) {
  8. die("skip gd extension not available.");
  9. }
  10. if (!function_exists("imagecolorstotal")) {
  11. die("skip imagecolorstotal() not available.");
  12. }
  13. ?>
  14. --FILE--
  15. <?php
  16. /* Prototype : int imagecolorstotal(resource im)
  17. * Description: Find out the number of colors in an image's palette
  18. * Source code: ext/gd/gd.c
  19. * Alias to functions:
  20. */
  21. echo "*** Testing imagecolorstotal() : basic functionality ***\n";
  22. // Palette image
  23. $img = imagecreate( 50, 50 );
  24. var_dump( imagecolorstotal( $img ) );
  25. $bg = imagecolorallocate( $img, 255, 255, 255 );
  26. var_dump( imagecolorstotal( $img ));
  27. $bg = imagecolorallocate( $img, 255, 0, 0 );
  28. $bg = imagecolorallocate( $img, 0, 0, 255 );
  29. var_dump( imagecolorstotal( $img ));
  30. imagedestroy( $img );
  31. // Truecolor image
  32. $img = imagecreatetruecolor( 50, 50 );
  33. var_dump( imagecolorstotal( $img ) );
  34. $bg = imagecolorallocate( $img, 255, 255, 255 );
  35. var_dump( imagecolorstotal( $img ) );
  36. imagedestroy( $img );
  37. ?>
  38. ===DONE===
  39. --EXPECT--
  40. *** Testing imagecolorstotal() : basic functionality ***
  41. int(0)
  42. int(1)
  43. int(3)
  44. int(0)
  45. int(0)
  46. ===DONE===