|
From: <be...@us...> - 2014-06-16 05:06:42
|
Revision: 12606
http://sourceforge.net/p/xoops/svn/12606
Author: beckmi
Date: 2014-06-16 05:06:36 +0000 (Mon, 16 Jun 2014)
Log Message:
-----------
Adding WideImage
Added Paths:
-----------
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Canvas.php
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Coordinate.php
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Exception.php
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Font/
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Font/GDF.php
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Font/PS.php
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Font/TTF.php
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Font/index.html
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Image.php
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Mapper/
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Mapper/BMP.php
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Mapper/GD.php
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Mapper/GD2.php
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Mapper/GIF.php
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Mapper/JPEG.php
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Mapper/PNG.php
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Mapper/TGA.php
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Mapper/index.html
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/MapperFactory.php
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/AddNoise.php
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/ApplyConvolution.php
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/ApplyFilter.php
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/ApplyMask.php
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/AsGrayscale.php
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/AsNegative.php
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/AutoCrop.php
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/CopyChannelsPalette.php
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/CopyChannelsTrueColor.php
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/CorrectGamma.php
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/Crop.php
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/Flip.php
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/GetMask.php
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/Merge.php
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/Mirror.php
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/Resize.php
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/ResizeCanvas.php
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/Rotate.php
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/RoundCorners.php
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/Unsharp.php
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/index.html
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/OperationFactory.php
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/PaletteImage.php
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/TrueColorImage.php
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/WideImage.php
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/docs/
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/docs/index.html
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/docs/readme.txt
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/index.html
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/vendor/
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/vendor/de77/
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/vendor/de77/BMP.php
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/vendor/de77/TGA.php
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/vendor/de77/index.html
XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/vendor/index.html
Added: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Canvas.php
===================================================================
--- XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Canvas.php (rev 0)
+++ XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Canvas.php 2014-06-16 05:06:36 UTC (rev 12606)
@@ -0,0 +1,61 @@
+<?php
+/*
+ WideImage_for_xoops
+ By CHG-WEB
+ 2012/04/08
+ Cédric MONTUY (montuy337513 / black_beard)
+ Original author : Gaspar Kozak
+*/
+if (!defined('XOOPS_ROOT_PATH')) {
+ die("XOOPS root path not defined");
+}
+class WideImage_NoFontException extends WideImage_Exception {}
+class WideImage_InvalidFontFileException extends WideImage_Exception {}
+class WideImage_InvalidCanvasMethodException extends WideImage_Exception {}
+class WideImage_Canvas{
+ protected $handle = 0;
+ protected $image = NULL;
+ protected $font = NULL;
+ function __construct($img){
+ $this->handle = $img->getHandle();
+ $this->image = $img;
+ }
+ function setFont($font){
+ $this->font = $font;
+ }
+ function useFont($file, $size = 12, $color = 0, $bgcolor = NULL){
+ $p = strrpos($file, '.');
+ if ($p === false || $p < strlen($file) - 4)
+ $ext = 'ttf';
+ else
+ $ext = strtolower(substr($file, $p + 1));
+ if ($ext == 'ttf' || $ext == 'otf')
+ $font = new WideImage_Font_TTF($file, $size, $color);
+ elseif ($ext == 'ps')
+ $font = new WideImage_Font_PS($file, $size, $color, $bgcolor);
+ elseif ($ext == 'gdf')
+ $font = new WideImage_Font_GDF($file, $color);
+ else
+ throw new WideImage_InvalidFontFileException('"'.$file.' appears to be an invalid font file.');
+ $this->setFont($font);
+ return $font;
+ }
+ function writeText($x, $y, $text, $angle = 0){
+ if ($this->font === NULL)
+ throw new WideImage_NoFontException("Can't write text without a font.");
+ $angle = - floatval($angle);
+ if ($angle < 0)
+ $angle = 360 + $angle;
+ $angle = $angle % 360;
+ $this->font->writeText($this->image, $x, $y, $text, $angle);
+ }
+ function __call($method, $params){
+ if (function_exists('image' . $method)) {
+ array_unshift($params, $this->handle);
+ call_user_func_array('image' . $method, $params);
+ }else{
+ throw new WideImage_InvalidCanvasMethodException("Function doesn't exist: image{$method}.");
+ }
+ }
+}
+?>
\ No newline at end of file
Property changes on: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Canvas.php
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev URL
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Coordinate.php
===================================================================
--- XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Coordinate.php (rev 0)
+++ XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Coordinate.php 2014-06-16 05:06:36 UTC (rev 12606)
@@ -0,0 +1,128 @@
+<?php
+/*
+ WideImage_for_xoops
+ By CHG-WEB
+ 2012/04/08
+ Cédric MONTUY (montuy337513 / black_beard)
+ Original author : Gaspar Kozak
+*/
+if (!defined('XOOPS_ROOT_PATH')) {
+ die("XOOPS root path not defined");
+}
+class WideImage_InvalidCoordinateException extends WideImage_Exception {}
+class WideImage_Coordinate{
+ static protected $coord_align = array("left", "center", "right", "top", "middle", "bottom");
+ static protected $coord_numeric = array("[0-9]+", "[0-9]+\.[0-9]+", "[0-9]+%", "[0-9]+\.[0-9]+%");
+ static function parse($c){
+ $tokens = array();
+ $operators = array('+', '-');
+ $flush_operand = false;
+ $flush_operator = false;
+ $current_operand = '';
+ $current_operator = '';
+ $coordinate = strval($c);
+ $expr_len = strlen($coordinate);
+ for ($i = 0; $i < $expr_len; $i++){
+ $char = $coordinate[$i];
+ if (in_array($char, $operators)){
+ $flush_operand = true;
+ $flush_operator = true;
+ $current_operator = $char;
+ }else{
+ $current_operand .= $char;
+ if ($i == $expr_len - 1)
+ $flush_operand = true;
+ }
+ if ($flush_operand) {
+ if (trim($current_operand) != '')
+ $tokens[] = array('type' => 'operand', 'value' => trim($current_operand));
+ $current_operand = '';
+ $flush_operand = false;
+ }
+ if ($flush_operator){
+ $tokens[] = array('type' => 'operator', 'value' => $char);
+ $flush_operator = false;
+ }
+ }
+ return $tokens;
+ }
+ static function evaluate($coord, $dim, $sec_dim = NULL) {
+ $comp_regex = implode('|', self::$coord_align) . '|' . implode('|', self::$coord_numeric);
+ if (preg_match("/^([+-])?({$comp_regex})$/", $coord, $matches)) {
+ $sign = intval($matches[1] . "1");
+ $val = $matches[2];
+ if (in_array($val, self::$coord_align)){
+ if ($sec_dim === NULL){
+ switch ($val){
+ case 'left':
+ case 'top':
+ return 0;
+ break;
+ case 'center':
+ case 'middle':
+ return $sign * intval($dim / 2);
+ break;
+ case 'right':
+ case 'bottom':
+ return $sign * $dim;
+ break;
+ default:
+ return NULL;
+ }
+ }else{
+ switch ($val){
+ case 'left':
+ case 'top':
+ return 0;
+ break;
+ case 'center':
+ case 'middle':
+ return $sign * intval($dim / 2 - $sec_dim / 2);
+ break;
+ case 'right':
+ case 'bottom':
+ return $sign * ($dim - $sec_dim);
+ break;
+ default:
+ return NULL;
+ }
+ }
+ }elseif (substr($val, -1) === '%'){
+ return intval(round($sign * $dim * floatval(str_replace('%', '', $val)) / 100));
+ }else{
+ return $sign * intval(round($val));
+ }
+ }
+ }
+ static function fix($value, $dim, $sec_dim = NULL){
+ $coord_tokens = self::parse($value);
+ if (count($coord_tokens) == 0 || $coord_tokens[count($coord_tokens) - 1]['type'] != 'operand')
+ throw new WideImage_InvalidCoordinateException("Couldn't parse coordinate '$value' properly.");
+ $value = 0;
+ $operation = 1;
+ foreach ($coord_tokens as $token){
+ if ($token['type'] == 'operand'){
+ $operand_value = self::evaluate($token['value'], $dim, $sec_dim);
+ if ($operation == 1)
+ $value = $value + $operand_value;
+ elseif ($operation == -1)
+ $value = $value - $operand_value;
+ else
+ throw new WideImage_InvalidCoordinateException("Invalid coordinate syntax.");
+ $operation = 0;
+ }elseif ($token['type'] == 'operator'){
+ if ($token['value'] == '-') {
+ if ($operation == 0)
+ $operation = -1;
+ else
+ $operation = $operation * -1;
+ }elseif ($token['value'] == '+'){
+ if ($operation == 0)
+ $operation = '1';
+ }
+ }
+ }
+ return $value;
+ }
+}
+?>
\ No newline at end of file
Property changes on: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Coordinate.php
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev URL
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Exception.php
===================================================================
--- XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Exception.php (rev 0)
+++ XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Exception.php 2014-06-16 05:06:36 UTC (rev 12606)
@@ -0,0 +1,13 @@
+<?php
+/*
+ WideImage_for_xoops
+ By CHG-WEB
+ 2012/04/08
+ Cédric MONTUY (montuy337513 / black_beard)
+ Original author : Gaspar Kozak
+*/
+if (!defined('XOOPS_ROOT_PATH')) {
+ die("XOOPS root path not defined");
+}
+ class WideImage_Exception extends RuntimeException {}
+?>
\ No newline at end of file
Property changes on: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Exception.php
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev URL
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Font/GDF.php
===================================================================
--- XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Font/GDF.php (rev 0)
+++ XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Font/GDF.php 2014-06-16 05:06:36 UTC (rev 12606)
@@ -0,0 +1,26 @@
+<?php
+/*
+ WideImage_for_xoops
+ By CHG-WEB
+ 2012/04/08
+ Cédric MONTUY (montuy337513 / black_beard)
+ Original author : Gaspar Kozak
+*/
+if (!defined('XOOPS_ROOT_PATH')) {
+ die("XOOPS root path not defined");
+}
+class WideImage_Font_GDF{
+ protected $font;
+ protected $color;
+ function __construct($face, $color) {
+ if (is_int($face) && $face >= 1 && $face <= 5)
+ $this->font = $face;
+ else
+ $this->font = imageloadfont($face);
+ $this->color = $color;
+ }
+ function writeText($image, $x, $y, $text){
+ imagestring($image->getHandle(), $this->font, $x, $y, $text, $this->color);
+ }
+}
+?>
\ No newline at end of file
Property changes on: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Font/GDF.php
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev URL
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Font/PS.php
===================================================================
--- XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Font/PS.php (rev 0)
+++ XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Font/PS.php 2014-06-16 05:06:36 UTC (rev 12606)
@@ -0,0 +1,35 @@
+<?php
+/*
+ WideImage_for_xoops
+ By CHG-WEB
+ 2012/04/08
+ Cédric MONTUY (montuy337513 / black_beard)
+ Original author : Gaspar Kozak
+*/
+if (!defined('XOOPS_ROOT_PATH')) {
+ die("XOOPS root path not defined");
+}
+class WideImage_Font_PS{
+ public $size;
+ public $color;
+ public $handle;
+ function __construct($file, $size, $color, $bgcolor = NULL) {
+ $this->handle = imagepsloadfont($file);
+ $this->size = $size;
+ $this->color = $color;
+ if ($bgcolor === NULL)
+ $this->bgcolor = $color;
+ else
+ $this->color = $color;
+ }
+ function writeText($image, $x, $y, $text, $angle = 0){
+ if ($image->isTrueColor())
+ $image->alphaBlending(true);
+ imagepstext($image->getHandle(), $text, $this->handle, $this->size, $this->color, $this->bgcolor, $x, $y, 0, 0, $angle, 4);
+ }
+ function __destruct(){
+ imagepsfreefont($this->handle);
+ $this->handle = NULL;
+ }
+}
+?>
\ No newline at end of file
Property changes on: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Font/PS.php
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev URL
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Font/TTF.php
===================================================================
--- XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Font/TTF.php (rev 0)
+++ XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Font/TTF.php 2014-06-16 05:06:36 UTC (rev 12606)
@@ -0,0 +1,40 @@
+<?php
+/*
+ WideImage_for_xoops
+ By CHG-WEB
+ 2012/04/08
+ Cédric MONTUY (montuy337513 / black_beard)
+ Original author : Gaspar Kozak
+*/
+if (!defined('XOOPS_ROOT_PATH')) {
+ die("XOOPS root path not defined");
+}
+class WideImage_Font_TTF{
+ public $face;
+ public $size;
+ public $color;
+ function __construct($face, $size, $color){
+ $this->face = $face;
+ $this->size = $size;
+ $this->color = $color;
+ }
+ function writeText($image, $x, $y, $text, $angle = 0){
+ if ($image->isTrueColor())
+ $image->alphaBlending(true);
+ $box = imageftbbox($this->size, $angle, $this->face, $text);
+ $obox = array(
+ 'left' => min($box[0], $box[2], $box[4], $box[6]),
+ 'top' => min($box[1], $box[3], $box[5], $box[7]),
+ 'right' => max($box[0], $box[2], $box[4], $box[6]) - 1,
+ 'bottom' => max($box[1], $box[3], $box[5], $box[7]) - 1
+ );
+ $obox['width'] = abs($obox['left']) + abs($obox['right']);
+ $obox['height'] = abs($obox['top']) + abs($obox['bottom']);
+ $x = WideImage_Coordinate::fix($x, $image->getWidth(), $obox['width']);
+ $y = WideImage_Coordinate::fix($y, $image->getHeight(), $obox['height']);
+ $fixed_x = $x - $obox['left'];
+ $fixed_y = $y - $obox['top'];
+ imagettftext($image->getHandle(), $this->size, $angle, $fixed_x, $fixed_y, $this->color, $this->face, $text);
+ }
+}
+?>
\ No newline at end of file
Property changes on: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Font/TTF.php
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev URL
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Font/index.html
===================================================================
--- XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Font/index.html (rev 0)
+++ XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Font/index.html 2014-06-16 05:06:36 UTC (rev 12606)
@@ -0,0 +1 @@
+ <script>history.go(-1);</script>
\ No newline at end of file
Added: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Image.php
===================================================================
--- XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Image.php (rev 0)
+++ XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Image.php 2014-06-16 05:06:36 UTC (rev 12606)
@@ -0,0 +1,250 @@
+<?php
+/*
+ WideImage_for_xoops
+ By CHG-WEB
+ 2012/04/08
+ Cédric MONTUY (montuy337513 / black_beard)
+ Original author : Gaspar Kozak
+*/
+if (!defined('XOOPS_ROOT_PATH')) {
+ die("XOOPS root path not defined");
+}
+class WideImage_InvalidImageDimensionException extends WideImage_Exception {}
+class WideImage_UnknownErrorWhileMappingException extends WideImage_Exception {}
+abstract class WideImage_Image{
+ protected $handle = NULL;
+ protected $handleReleased = false;
+ protected $canvas = NULL;
+ protected $sdata = NULL;
+ function __construct($handle){
+ WideImage::assertValidImageHandle($handle);
+ $this->handle = $handle;
+ }
+ function __destruct(){
+ $this->destroy();
+ }
+ function destroy(){
+ if ($this->isValid() && !$this->handleReleased)
+ imagedestroy($this->handle);
+ $this->handle = NULL;
+ }
+ function getHandle(){
+ return $this->handle;
+ }
+ function isValid(){
+ return WideImage::isValidImageHandle($this->handle);
+ }
+ function releaseHandle(){
+ $this->handleReleased = true;
+ }
+ function saveToFile($uri){
+ $mapper = WideImage_MapperFactory::selectMapper($uri, NULL);
+ $args = func_get_args();
+ array_unshift($args, $this->getHandle());
+ $res = call_user_func_array(array($mapper, 'save'), $args);
+ if (!$res)
+ throw new WideImage_UnknownErrorWhileMappingException(get_class($mapper) . ' returned an invalid result while saving to '.$uri);
+ }
+ function asString($format){
+ ob_start();
+ $args = func_get_args();
+ $args[0] = NULL;
+ array_unshift($args, $this->getHandle());
+ $mapper = WideImage_MapperFactory::selectMapper(null, $format);
+ $res = call_user_func_array(array($mapper, 'save'), $args);
+ if (!$res)
+ throw new WideImage_UnknownErrorWhileMappingException(get_class($mapper) . ' returned an invalid result while writing the image data');
+ return ob_get_clean();
+ }
+ protected function writeHeader($name, $data){
+ header($name . ': ' . $data);
+ }
+ function output($format){
+ $args = func_get_args();
+ $data = call_user_func_array(array($this, 'asString'), $args);
+ $this->writeHeader('Content-length', strlen($data));
+ $this->writeHeader('Content-type', WideImage_MapperFactory::mimeType($format));
+ echo $data;
+ }
+ function getWidth(){
+ return imagesx($this->handle);
+ }
+ function getHeight(){
+ return imagesy($this->handle);
+ }
+ function allocateColor($R, $G = NULL, $B = NULL){
+ if (is_array($R))
+ return imageColorAllocate($this->handle, $R['red'], $R['green'], $R['blue']);
+ else
+ return imageColorAllocate($this->handle, $R, $G, $B);
+ }
+ function isTransparent(){
+ return $this->getTransparentColor() >= 0;
+ }
+ function getTransparentColor(){
+ return imagecolortransparent($this->handle);
+ }
+ function setTransparentColor($color){
+ return imagecolortransparent($this->handle, $color);
+ }
+ function getTransparentColorRGB(){
+ $total = imagecolorstotal($this->handle);
+ $tc = $this->getTransparentColor();
+ if ($tc >= $total && $total > 0)
+ return NULL;
+ else
+ return $this->getColorRGB($tc);
+ }
+ function getRGBAt($x, $y){
+ return $this->getColorRGB($this->getColorAt($x, $y));
+ }
+ function setRGBAt($x, $y, $color){
+ $this->setColorAt($x, $y, $this->getExactColor($color));
+ }
+ function getColorRGB($colorIndex){
+ return imageColorsForIndex($this->handle, $colorIndex);
+ }
+ function getColorAt($x, $y) {
+ return imagecolorat($this->handle, $x, $y);
+ }
+ function setColorAt($x, $y, $color) {
+ return imagesetpixel($this->handle, $x, $y, $color);
+ }
+ function getClosestColor($R, $G = NULL, $B = NULL){
+ if (is_array($R))
+ return imagecolorclosest($this->handle, $R['red'], $R['green'], $R['blue']);
+ else
+ return imagecolorclosest($this->handle, $R, $G, $B);
+ }
+ function getExactColor($R, $G = NULL, $B = NULL){
+ if (is_array($R))
+ return imagecolorexact($this->handle, $R['red'], $R['green'], $R['blue']);
+ else
+ return imagecolorexact($this->handle, $R, $G, $B);
+ }
+ function copyTransparencyFrom($sourceImage, $fill = true){
+ if ($sourceImage->isTransparent()){
+ $rgba = $sourceImage->getTransparentColorRGB();
+ if ($rgba === NULL)
+ return;
+ if ($this->isTrueColor()){
+ $rgba['alpha'] = 127;
+ $color = $this->allocateColorAlpha($rgba);
+ }else{
+ $color = $this->allocateColor($rgba);
+ }
+ $this->setTransparentColor($color);
+ if ($fill)
+ $this->fill(0, 0, $color);
+ }
+ }
+ function fill($x, $y, $color){
+ return imagefill($this->handle, $x, $y, $color);
+ }
+ protected function getOperation($name){
+ return WideImage_OperationFactory::get($name);
+ }
+ function getMask(){
+ return $this->getOperation('GetMask')->execute($this);
+ }
+ function resize($width = NULL, $height = NULL, $fit = 'inside', $scale = 'any') {
+ return $this->getOperation('Resize')->execute($this, $width, $height, $fit, $scale);
+ }
+ function resizeDown($width = NULL, $height = NULL, $fit = 'inside') {
+ return $this->resize($width, $height, $fit, 'down');
+ }
+ function resizeUp($width = NULL, $height = NULL, $fit = 'inside'){
+ return $this->resize($width, $height, $fit, 'up');
+ }
+ function rotate($angle, $bgColor = NULL, $ignoreTransparent = true) {
+ return $this->getOperation('Rotate')->execute($this, $angle, $bgColor, $ignoreTransparent);
+ }
+ function merge($overlay, $left = 0, $top = 0, $pct = 100){
+ return $this->getOperation('Merge')->execute($this, $overlay, $left, $top, $pct);
+ }
+ function resizeCanvas($width, $height, $pos_x, $pos_y, $bg_color = NULL, $scale = 'any', $merge = false){
+ return $this->getOperation('ResizeCanvas')->execute($this, $width, $height, $pos_x, $pos_y, $bg_color, $scale, $merge);
+ }
+ function roundCorners($radius, $color = NULL, $smoothness = 2, $corners = 255){
+ return $this->getOperation('RoundCorners')->execute($this, $radius, $color, $smoothness, $corners);
+ }
+ function applyMask($mask, $left = 0, $top = 0){
+ return $this->getOperation('ApplyMask')->execute($this, $mask, $left, $top);
+ }
+ function applyFilter($filter, $arg1 = NULL, $arg2 = NULL, $arg3 = NULL, $arg4 = NULL){
+ return $this->getOperation('ApplyFilter')->execute($this, $filter, $arg1, $arg2, $arg3, $arg4);
+ }
+ function applyConvolution($matrix, $div, $offset){
+ return $this->getOperation('ApplyConvolution')->execute($this, $matrix, $div, $offset);
+ }
+ function crop($left = 0, $top = 0, $width = '100%', $height = '100%'){
+ return $this->getOperation('Crop')->execute($this, $left, $top, $width, $height);
+ }
+ function autoCrop($margin = 0, $rgb_threshold = 0, $pixel_cutoff = 1, $base_color = NULL){
+ return $this->getOperation('AutoCrop')->execute($this, $margin, $rgb_threshold, $pixel_cutoff, $base_color);
+ }
+ function asNegative(){
+ return $this->getOperation('AsNegative')->execute($this);
+ }
+ function asGrayscale(){
+ return $this->getOperation('AsGrayscale')->execute($this);
+ }
+ function mirror(){
+ return $this->getOperation('Mirror')->execute($this);
+ }
+ function unsharp($amount, $radius, $threshold){
+ return $this->getOperation('Unsharp')->execute($this, $amount, $radius, $threshold);
+ }
+ function flip() {
+ return $this->getOperation('Flip')->execute($this);
+ }
+ function correctGamma($inputGamma, $outputGamma){
+ return $this->getOperation('CorrectGamma')->execute($this, $inputGamma, $outputGamma);
+ }
+ function addNoise($amount, $type){
+ return $this->getOperation('AddNoise')->execute($this, $amount, $type);
+ }
+ function __call($name, $args){
+ $op = $this->getOperation($name);
+ array_unshift($args, $this);
+ return call_user_func_array(array($op, 'execute'), $args);
+ }
+ function __toString(){
+ if ($this->isTransparent())
+ return $this->asString('gif');
+ else
+ return $this->asString('png');
+ }
+ function copy() {
+ $dest = $this->doCreate($this->getWidth(), $this->getHeight());
+ $dest->copyTransparencyFrom($this, true);
+ $this->copyTo($dest, 0, 0);
+ return $dest;
+ }
+ function copyTo($dest, $left = 0, $top = 0) {
+ if (!imagecopy($dest->getHandle(), $this->handle, $left, $top, 0, 0, $this->getWidth(), $this->getHeight()))
+ throw new WideImage_GDFunctionResultException("imagecopy() returned false");
+ }
+ function getCanvas(){
+ if ($this->canvas == NULL)
+ $this->canvas = new WideImage_Canvas($this);
+ return $this->canvas;
+ }
+ abstract function isTrueColor();
+ abstract function asTrueColor();
+ abstract function asPalette($nColors = 255, $dither = NULL, $matchPalette = true);
+ abstract function getChannels();
+ abstract function copyNoAlpha();
+ function __sleep() {
+ $this->sdata = $this->asString('png');
+ return array('sdata', 'handleReleased');
+ }
+ function __wakeup() {
+ $temp_image = WideImage::loadFromString($this->sdata);
+ $temp_image->releaseHandle();
+ $this->handle = $temp_image->handle;
+ $temp_image = NULL;
+ $this->sdata = NULL;
+ }
+ }
+?>
\ No newline at end of file
Property changes on: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Image.php
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev URL
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Mapper/BMP.php
===================================================================
--- XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Mapper/BMP.php (rev 0)
+++ XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Mapper/BMP.php 2014-06-16 05:06:36 UTC (rev 12606)
@@ -0,0 +1,27 @@
+<?php
+/*
+ WideImage_for_xoops
+ By CHG-WEB
+ 2012/04/08
+ Cédric MONTUY (montuy337513 / black_beard)
+ Original author : Gaspar Kozak
+*/
+if (!defined('XOOPS_ROOT_PATH')) {
+ die("XOOPS root path not defined");
+}
+include_once WideImage::path() . '/vendor/de77/BMP.php';
+class WideImage_Mapper_BMP{
+ function load($uri){
+ return WideImage_vendor_de77_BMP::imagecreatefrombmp($uri);
+ }
+ function loadFromString($data){
+ return WideImage_vendor_de77_BMP::imagecreatefromstring($data);
+ }
+ function save($handle, $uri = NULL){
+ if ($uri == NULL)
+ return WideImage_vendor_de77_BMP::imagebmp($handle);
+ else
+ return WideImage_vendor_de77_BMP::imagebmp($handle, $uri);
+ }
+}
+?>
\ No newline at end of file
Property changes on: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Mapper/BMP.php
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev URL
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Mapper/GD.php
===================================================================
--- XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Mapper/GD.php (rev 0)
+++ XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Mapper/GD.php 2014-06-16 05:06:36 UTC (rev 12606)
@@ -0,0 +1,23 @@
+<?php
+/*
+ WideImage_for_xoops
+ By CHG-WEB
+ 2012/04/08
+ Cédric MONTUY (montuy337513 / black_beard)
+ Original author : Gaspar Kozak
+*/
+if (!defined('XOOPS_ROOT_PATH')) {
+ die("XOOPS root path not defined");
+}
+class WideImage_Mapper_GD{
+ function load($uri) {
+ return @imagecreatefromgd($uri);
+ }
+ function save($handle, $uri = NULL){
+ if ($uri == NULL)
+ return imagegd($handle);
+ else
+ return imagegd($handle, $uri);
+ }
+}
+?>
\ No newline at end of file
Property changes on: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Mapper/GD.php
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev URL
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Mapper/GD2.php
===================================================================
--- XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Mapper/GD2.php (rev 0)
+++ XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Mapper/GD2.php 2014-06-16 05:06:36 UTC (rev 12606)
@@ -0,0 +1,20 @@
+<?php
+/*
+ WideImage_for_xoops
+ By CHG-WEB
+ 2012/04/08
+ Cédric MONTUY (montuy337513 / black_beard)
+ Original author : Gaspar Kozak
+*/
+if (!defined('XOOPS_ROOT_PATH')) {
+ die("XOOPS root path not defined");
+}
+class WideImage_Mapper_GD2{
+ function load($uri){
+ return @imagecreatefromgd2($uri);
+ }
+ function save($handle, $uri = NULL, $chunk_size = NULL, $type = NULL){
+ return imagegd2($handle, $uri, $chunk_size, $type);
+ }
+}
+?>
\ No newline at end of file
Property changes on: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Mapper/GD2.php
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev URL
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Mapper/GIF.php
===================================================================
--- XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Mapper/GIF.php (rev 0)
+++ XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Mapper/GIF.php 2014-06-16 05:06:36 UTC (rev 12606)
@@ -0,0 +1,23 @@
+<?php
+/*
+ WideImage_for_xoops
+ By CHG-WEB
+ 2012/04/08
+ Cédric MONTUY (montuy337513 / black_beard)
+ Original author : Gaspar Kozak
+*/
+if (!defined('XOOPS_ROOT_PATH')) {
+ die("XOOPS root path not defined");
+}
+class WideImage_Mapper_GIF{
+ function load($uri) {
+ return @imagecreatefromgif($uri);
+ }
+ function save($handle, $uri = NULL) {
+ if ($uri)
+ return imagegif($handle, $uri);
+ else
+ return imagegif($handle);
+ }
+}
+?>
\ No newline at end of file
Property changes on: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Mapper/GIF.php
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev URL
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Mapper/JPEG.php
===================================================================
--- XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Mapper/JPEG.php (rev 0)
+++ XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Mapper/JPEG.php 2014-06-16 05:06:36 UTC (rev 12606)
@@ -0,0 +1,20 @@
+<?php
+/*
+ WideImage_for_xoops
+ By CHG-WEB
+ 2012/04/08
+ Cédric MONTUY (montuy337513 / black_beard)
+ Original author : Gaspar Kozak
+*/
+if (!defined('XOOPS_ROOT_PATH')) {
+ die("XOOPS root path not defined");
+}
+class WideImage_Mapper_JPEG{
+ function load($uri){
+ return @imagecreatefromjpeg($uri);
+ }
+ function save($handle, $uri = NULL, $quality = 100){
+ return imagejpeg($handle, $uri, $quality);
+ }
+}
+?>
\ No newline at end of file
Property changes on: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Mapper/JPEG.php
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev URL
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Mapper/PNG.php
===================================================================
--- XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Mapper/PNG.php (rev 0)
+++ XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Mapper/PNG.php 2014-06-16 05:06:36 UTC (rev 12606)
@@ -0,0 +1,20 @@
+<?php
+/*
+ WideImage_for_xoops
+ By CHG-WEB
+ 2012/04/08
+ Cédric MONTUY (montuy337513 / black_beard)
+ Original author : Gaspar Kozak
+*/
+if (!defined('XOOPS_ROOT_PATH')) {
+ die("XOOPS root path not defined");
+}
+class WideImage_Mapper_PNG{
+ function load($uri){
+ return @imagecreatefrompng($uri);
+ }
+ function save($handle, $uri = NULL, $compression = 9, $filters = PNG_ALL_FILTERS){
+ return imagepng($handle, $uri, $compression, $filters);
+ }
+}
+?>
\ No newline at end of file
Property changes on: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Mapper/PNG.php
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev URL
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Mapper/TGA.php
===================================================================
--- XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Mapper/TGA.php (rev 0)
+++ XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Mapper/TGA.php 2014-06-16 05:06:36 UTC (rev 12606)
@@ -0,0 +1,24 @@
+<?php
+/*
+ WideImage_for_xoops
+ By CHG-WEB
+ 2012/04/08
+ Cédric MONTUY (montuy337513 / black_beard)
+ Original author : Gaspar Kozak
+*/
+if (!defined('XOOPS_ROOT_PATH')) {
+ die("XOOPS root path not defined");
+}
+include_once WideImage::path() . '/vendor/de77/TGA.php';
+class WideImage_Mapper_TGA{
+ function load($uri){
+ return WideImage_vendor_de77_TGA::imagecreatefromtga($uri);
+ }
+ function loadFromString($data){
+ return WideImage_vendor_de77_TGA::imagecreatefromstring($data);
+ }
+ function save($handle, $uri = NULL){
+ throw new WideImage_Exception("Saving to TGA isn't supported.");
+ }
+}
+?>
\ No newline at end of file
Property changes on: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Mapper/TGA.php
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev URL
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Mapper/index.html
===================================================================
--- XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Mapper/index.html (rev 0)
+++ XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Mapper/index.html 2014-06-16 05:06:36 UTC (rev 12606)
@@ -0,0 +1 @@
+ <script>history.go(-1);</script>
\ No newline at end of file
Added: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/MapperFactory.php
===================================================================
--- XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/MapperFactory.php (rev 0)
+++ XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/MapperFactory.php 2014-06-16 05:06:36 UTC (rev 12606)
@@ -0,0 +1,69 @@
+<?php
+/*
+ WideImage_for_xoops
+ By CHG-WEB
+ 2012/04/08
+ Cédric MONTUY (montuy337513 / black_beard)
+ Original author : Gaspar Kozak
+*/
+if (!defined('XOOPS_ROOT_PATH')) {
+ die("XOOPS root path not defined");
+}
+class WideImage_UnsupportedFormatException extends WideImage_Exception {}
+ abstract class WideImage_MapperFactory{
+ static protected $mappers = array();
+ static protected $customMappers = array();
+ static protected $mimeTable = array(
+ 'image/jpg' => 'JPEG',
+ 'image/jpeg' => 'JPEG',
+ 'image/pjpeg' => 'JPEG',
+ 'image/gif' => 'GIF',
+ 'image/png' => 'PNG'
+ );
+ static function selectMapper($uri, $format = NULL){
+ $format = self::determineFormat($uri, $format);
+ if (array_key_exists($format, self::$mappers))
+ return self::$mappers[$format];
+ $mapperClassName = 'WideImage_Mapper_' . $format;
+ if (!class_exists($mapperClassName, false)) {
+ $mapperFileName = WideImage::path() . 'Mapper/' . $format . '.php';
+ if (file_exists($mapperFileName))
+ require_once $mapperFileName;
+ }
+ if (class_exists($mapperClassName)){
+ self::$mappers[$format] = new $mapperClassName();
+ return self::$mappers[$format];
+ }
+ throw new WideImage_UnsupportedFormatException("Format '{$format}' is not supported.");
+ }
+ static function registerMapper($mapper_class_name, $mime_type, $extension){
+ self::$customMappers[$mime_type] = $mapper_class_name;
+ self::$mimeTable[$mime_type] = $extension;
+ }
+ static function getCustomMappers(){
+ return self::$customMappers;
+ }
+ static function determineFormat($uri, $format = NULL){
+ if ($format == NULL)
+ $format = self::extractExtension($uri);
+ if (preg_match('~[a-z]*/[a-z-]*~i', $format))
+ if (isset(self::$mimeTable[strtolower($format)])){
+ return self::$mimeTable[strtolower($format)];
+ }
+ $format = strtoupper(preg_replace('/[^a-z0-9_-]/i', '', $format));
+ if ($format == 'JPG')
+ $format = 'JPEG';
+ return $format;
+ }
+ static function mimeType($format){
+ return array_search(strtoupper($format), self::$mimeTable);
+ }
+ static function extractExtension($uri){
+ $p = strrpos($uri, '.');
+ if ($p === false)
+ return '';
+ else
+ return substr($uri, $p + 1);
+ }
+}
+?>
\ No newline at end of file
Property changes on: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/MapperFactory.php
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev URL
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/AddNoise.php
===================================================================
--- XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/AddNoise.php (rev 0)
+++ XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/AddNoise.php 2014-06-16 05:06:36 UTC (rev 12606)
@@ -0,0 +1,70 @@
+<?php
+/*
+ WideImage_for_xoops
+ By CHG-WEB
+ 2012/04/08
+ Cédric MONTUY (montuy337513 / black_beard)
+ Original author : Gaspar Kozak
+*/
+if (!defined('XOOPS_ROOT_PATH')) {
+ die("XOOPS root path not defined");
+}
+class WideImage_Operation_AddNoise {
+ function execute($image, $amount, $type) {
+ switch ($type){
+ case 'salt&pepper':
+ $fun = 'saltPepperNoise_fun';
+ break;
+ case 'color':
+ $fun = 'colorNoise_fun';
+ break;
+ default :
+ $fun = 'monoNoise_fun';
+ }
+ return self::filter($image->asTrueColor(), $fun, $amount);
+ }
+ function filter($image, $function, $value){
+ for ($y = 0; $y < $image->getHeight(); $y++){
+ for ($x = 0; $x< $image->getWidth(); $x++){
+ $rgb = imagecolorat($image->getHandle(), $x, $y);
+ $a = ($rgb >> 24) & 0xFF;
+ $r = ($rgb >> 16) & 0xFF;
+ $g = ($rgb >> 8) & 0xFF;
+ $b = $rgb & 0xFF;
+ self::$function($r, $g, $b, $value);
+ $color = imagecolorallocatealpha($image->getHandle(), $r, $g, $b, $a);
+ imagesetpixel($image->getHandle(), $x, $y, $color);
+ }
+ }
+ return $image;
+ }
+ function colorNoise_fun(&$r, &$g, &$b, $amount) {
+ $r = self::byte($r + mt_rand(0, $amount) - ($amount >> 1) );
+ $g = self::byte($g + mt_rand(0, $amount) - ($amount >> 1) );
+ $b = self::byte($b + mt_rand(0, $amount) - ($amount >> 1) );
+ }
+ function monoNoise_fun(&$r, &$g, &$b, $amount){
+ $rand = mt_rand(0, $amount) - ($amount >> 1);
+ $r = self::byte($r + $rand);
+ $g = self::byte($g + $rand);
+ $b = self::byte($b + $rand);
+ }
+ function saltPepperNoise_fun(&$r, &$g, &$b, $amount){
+ if (mt_rand(0, 255 - $amount) != 0) return;
+ $rand = mt_rand(0, 1);
+ switch ($rand){
+ case 0 :
+ $r = $g = $b = 0;
+ break;
+ case 1 :
+ $r = $g = $b = 255;
+ break;
+ }
+ }
+ function byte($b){
+ if ($b > 255) return 255;
+ if ($b < 0) return 0;
+ return (int) $b;
+ }
+}
+?>
\ No newline at end of file
Property changes on: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/AddNoise.php
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev URL
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/ApplyConvolution.php
===================================================================
--- XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/ApplyConvolution.php (rev 0)
+++ XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/ApplyConvolution.php 2014-06-16 05:06:36 UTC (rev 12606)
@@ -0,0 +1,20 @@
+<?php
+/*
+ WideImage_for_xoops
+ By CHG-WEB
+ 2012/04/08
+ Cédric MONTUY (montuy337513 / black_beard)
+ Original author : Gaspar Kozak
+*/
+if (!defined('XOOPS_ROOT_PATH')) {
+ die("XOOPS root path not defined");
+}
+class WideImage_Operation_ApplyConvolution{
+ function execute($image, $matrix, $div, $offset){
+ $new = $image->asTrueColor();
+ if (!imageconvolution($new->getHandle(), $matrix, $div, $offset))
+ throw new WideImage_GDFunctionResultException('imageconvolution() returned false');
+ return $new;
+ }
+}
+?>
\ No newline at end of file
Property changes on: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/ApplyConvolution.php
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev URL
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/ApplyFilter.php
===================================================================
--- XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/ApplyFilter.php (rev 0)
+++ XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/ApplyFilter.php 2014-06-16 05:06:36 UTC (rev 12606)
@@ -0,0 +1,29 @@
+<?php
+/*
+ WideImage_for_xoops
+ By CHG-WEB
+ 2012/04/08
+ Cédric MONTUY (montuy337513 / black_beard)
+ Original author : Gaspar Kozak
+*/
+if (!defined('XOOPS_ROOT_PATH')) {
+ die("XOOPS root path not defined");
+}
+class WideImage_Operation_ApplyFilter{
+ static protected $one_arg_filters = array(IMG_FILTER_SMOOTH, IMG_FILTER_CONTRAST, IMG_FILTER_BRIGHTNESS);
+ function execute($image, $filter, $arg1 = NULL, $arg2 = NULL, $arg3 = NULL, $arg4 = NULL){
+ $new = $image->asTrueColor();
+ if (in_array($filter, self::$one_arg_filters))
+ $res = imagefilter($new->getHandle(), $filter, $arg1);
+ elseif (defined('IMG_FILTER_PIXELATE') && $filter == IMG_FILTER_PIXELATE)
+ $res = imagefilter($new->getHandle(), $filter, $arg1, $arg2);
+ elseif ($filter == IMG_FILTER_COLORIZE)
+ $res = imagefilter($new->getHandle(), $filter, $arg1, $arg2, $arg3, $arg4);
+ else
+ $res = imagefilter($new->getHandle(), $filter);
+ if (!$res)
+ throw new WideImage_GDFunctionResultException("imagefilter() returned false");
+ return $new;
+ }
+}
+?>
\ No newline at end of file
Property changes on: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/ApplyFilter.php
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev URL
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/ApplyMask.php
===================================================================
--- XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/ApplyMask.php (rev 0)
+++ XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/ApplyMask.php 2014-06-16 05:06:36 UTC (rev 12606)
@@ -0,0 +1,59 @@
+<?php
+/*
+ WideImage_for_xoops
+ By CHG-WEB
+ 2012/04/08
+ Cédric MONTUY (montuy337513 / black_beard)
+ Original author : Gaspar Kozak
+*/
+if (!defined('XOOPS_ROOT_PATH')) {
+ die("XOOPS root path not defined");
+}
+class WideImage_Operation_ApplyMask{
+ function execute($image, $mask, $left = 0, $top = 0){
+ $left = WideImage_Coordinate::fix($left, $image->getWidth(), $mask->getWidth());
+ $top = WideImage_Coordinate::fix($top, $image->getHeight(), $mask->getHeight());
+ $width = $image->getWidth();
+ $mask_width = $mask->getWidth();
+ $height = $image->getHeight();
+ $mask_height = $mask->getHeight();
+ $result = $image->asTrueColor();
+ $result->alphaBlending(false);
+ $result->saveAlpha(true);
+ $srcTransparentColor = $result->getTransparentColor();
+ if ($srcTransparentColor >= 0){
+ $destTransparentColor = $srcTransparentColor;
+ }else{
+ $destTransparentColor = $result->allocateColorAlpha(255, 255, 255, 127);
+ }
+ for ($x = 0; $x < $width; $x++)
+ for ($y = 0; $y < $height; $y++){
+ $mx = $x - $left;
+ $my = $y - $top;
+ if ($mx >= 0 && $mx < $mask_width && $my >= 0 && $my < $mask_height){
+ $srcColor = $image->getColorAt($x, $y);
+ if ($srcColor == $srcTransparentColor){
+ $destColor = $destTransparentColor;
+ }else{
+ $maskRGB = $mask->getRGBAt($mx, $my);
+ if ($maskRGB['red'] == 0) {
+ $destColor = $destTransparentColor;
+ } elseif ($srcColor >= 0){
+ $imageRGB = $image->getRGBAt($x, $y);
+ $level = ($maskRGB['red'] / 255) * (1 - $imageRGB['alpha'] / 127);
+ $imageRGB['alpha'] = 127 - round($level * 127);
+ if ($imageRGB['alpha'] == 127)
+ $destColor = $destTransparentColor;
+ else
+ $destColor = $result->allocateColorAlpha($imageRGB);
+ }else{
+ $destColor = $destTransparentColor;
+ }
+ }
+ $result->setColorAt($x, $y, $destColor);
+ }
+ }
+ return $result;
+ }
+}
+?>
\ No newline at end of file
Property changes on: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/ApplyMask.php
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev URL
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/AsGrayscale.php
===================================================================
--- XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/AsGrayscale.php (rev 0)
+++ XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/AsGrayscale.php 2014-06-16 05:06:36 UTC (rev 12606)
@@ -0,0 +1,22 @@
+<?php
+/*
+ WideImage_for_xoops
+ By CHG-WEB
+ 2012/04/08
+ Cédric MONTUY (montuy337513 / black_beard)
+ Original author : Gaspar Kozak
+*/
+if (!defined('XOOPS_ROOT_PATH')) {
+ die("XOOPS root path not defined");
+}
+class WideImage_Operation_AsGrayscale{
+ function execute($image){
+ $new = $image->asTrueColor();
+ if (!imagefilter($new->getHandle(), IMG_FILTER_GRAYSCALE))
+ throw new WideImage_GDFunctionResultException('imagefilter() returned false');
+ if (!$image->isTrueColor())
+ $new = $new->asPalette();
+ return $new;
+ }
+}
+?>
\ No newline at end of file
Property changes on: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/AsGrayscale.php
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev URL
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/AsNegative.php
===================================================================
--- XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/AsNegative.php (rev 0)
+++ XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/AsNegative.php 2014-06-16 05:06:36 UTC (rev 12606)
@@ -0,0 +1,32 @@
+<?php
+/*
+ WideImage_for_xoops
+ By CHG-WEB
+ 2012/04/08
+ Cédric MONTUY (montuy337513 / black_beard)
+ Original author : Gaspar Kozak
+*/
+if (!defined('XOOPS_ROOT_PATH')) {
+ die("XOOPS root path not defined");
+}
+class WideImage_Operation_AsNegative{
+ function execute($image){
+ $palette = !$image->isTrueColor();
+ $transparent = $image->isTransparent();
+ if ($palette && $transparent)
+ $tcrgb = $image->getTransparentColorRGB();
+ $new = $image->asTrueColor();
+ if (!imagefilter($new->getHandle(), IMG_FILTER_NEGATE))
+ throw new WideImage_GDFunctionResultException("imagefilter() returned false");
+ if ($palette){
+ $new = $new->asPalette();
+ if ($transparent){
+ $irgb = array('red' => 255 - $tcrgb['red'], 'green' => 255 - $tcrgb['green'], 'blue' => 255 - $tcrgb['blue'], 'alpha' => 127);
+ $new_tci = imagecolorexactalpha($new->getHandle(), $irgb['red'], $irgb['green'], $irgb['blue'], 127);
+ $new->setTransparentColor($new_tci);
+ }
+ }
+ return $new;
+ }
+}
+?>
\ No newline at end of file
Property changes on: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/AsNegative.php
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev URL
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/AutoCrop.php
===================================================================
--- XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/AutoCrop.php (rev 0)
+++ XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/AutoCrop.php 2014-06-16 05:06:36 UTC (rev 12606)
@@ -0,0 +1,102 @@
+<?php
+/*
+ WideImage_for_xoops
+ By CHG-WEB
+ 2012/04/08
+ Cédric MONTUY (montuy337513 / black_beard)
+ Original author : Gaspar Kozak
+*/
+if (!defined('XOOPS_ROOT_PATH')) {
+ die("XOOPS root path not defined");
+}
+class WideImage_Operation_AutoCrop{
+ function execute($img, $margin, $rgb_threshold, $pixel_cutoff, $base_color) {
+ $margin = intval($margin);
+ $rgb_threshold = intval($rgb_threshold);
+ if ($rgb_threshold < 0)
+ $rgb_threshold = 0;
+ $pixel_cutoff = intval($pixel_cutoff);
+ if ($pixel_cutoff <= 1)
+ $pixel_cutoff = 1;
+ if ($base_color === NULL){
+ $rgb_base = $img->getRGBAt(0, 0);
+ }else{
+ if ($base_color < 0)
+ return $img->copy();
+ $rgb_base = $img->getColorRGB($base_color);
+ }
+ $cut_rect = array('left' => 0, 'top' => 0, 'right' => $img->getWidth() - 1, 'bottom' => $img->getHeight() - 1);
+ for ($y = 0; $y <= $cut_rect['bottom']; $y++){
+ $count = 0;
+ for ($x = 0; $x <= $cut_rect['right']; $x++){
+ $rgb = $img->getRGBAt($x, $y);
+ $diff = abs($rgb['red'] - $rgb_base['red']) + abs($rgb['green'] - $rgb_base['green']) + abs($rgb['blue'] - $rgb_base['blue']);
+ if ($diff > $rgb_threshold) {
+ $count++;
+ if ($count >= $pixel_cutoff){
+ $cut_rect['top'] = $y;
+ break 2;
+ }
+ }
+ }
+ }
+ for ($y = $img->getHeight() - 1; $y >= $cut_rect['top']; $y--){
+ $count = 0;
+ for ($x = 0; $x <= $cut_rect['right']; $x++){
+ $rgb = $img->getRGBAt($x, $y);
+ $diff = abs($rgb['red'] - $rgb_base['red']) + abs($rgb['green'] - $rgb_base['green']) + abs($rgb['blue'] - $rgb_base['blue']);
+ if ($diff > $rgb_threshold){
+ $count++;
+ if ($count >= $pixel_cutoff){
+ $cut_rect['bottom'] = $y;
+ break 2;
+ }
+ }
+ }
+ }
+ for ($x = 0; $x <= $cut_rect['right']; $x++){
+ $count = 0;
+ for ($y = $cut_rect['top']; $y <= $cut_rect['bottom']; $y++){
+ $rgb = $img->getRGBAt($x, $y);
+ $diff = abs($rgb['red'] - $rgb_base['red']) + abs($rgb['green'] - $rgb_base['green']) + abs($rgb['blue'] - $rgb_base['blue']);
+ if ($diff > $rgb_threshold) {
+ $count++;
+ if ($count >= $pixel_cutoff){
+ $cut_rect['left'] = $x;
+ break 2;
+ }
+ }
+ }
+ }
+ for ($x = $cut_rect['right']; $x >= $cut_rect['left']; $x--){
+ $count = 0;
+ for ($y = $cut_rect['top']; $y <= $cut_rect['bottom']; $y++){
+ $rgb = $img->getRGBAt($x, $y);
+ $diff = abs($rgb['red'] - $rgb_base['red']) + abs($rgb['green'] - $rgb_base['green']) + abs($rgb['blue'] - $rgb_base['blue']);
+ if ($diff > $rgb_threshold) {
+ $count++;
+ if ($count >= $pixel_cutoff){
+ $cut_rect['right'] = $x;
+ break 2;
+ }
+ }
+ }
+ }
+ $cut_rect = array(
+ 'left' => $cut_rect['left'] - $margin,
+ 'top' => $cut_rect['top'] - $margin,
+ 'right' => $cut_rect['right'] + $margin,
+ 'bottom' => $cut_rect['bottom'] + $margin
+ );
+ if ($cut_rect['left'] < 0)
+ $cut_rect['left'] = 0;
+ if ($cut_rect['top'] < 0)
+ $cut_rect['top'] = 0;
+ if ($cut_rect['right'] >= $img->getWidth())
+ $cut_rect['right'] = $img->getWidth() - 1;
+ if ($cut_rect['bottom'] >= $img->getHeight())
+ $cut_rect['bottom'] = $img->getHeight() - 1;
+ return $img->crop($cut_rect['left'], $cut_rect['top'], $cut_rect['right'] - $cut_rect['left'] + 1, $cut_rect['bottom'] - $cut_rect['top'] + 1);
+ }
+}
+?>
\ No newline at end of file
Property changes on: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/AutoCrop.php
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev URL
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/CopyChannelsPalette.php
===================================================================
--- XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/CopyChannelsPalette.php (rev 0)
+++ XoopsModules/modulepacks/x257basicmodulepack/trunk/xoops_lib/vendor/wideimage/Operation/CopyChannelsPalette.php 2014-06-16 05:06:36 UTC (rev 12606)
@@ -0,0 +1,49 @@
+<?php
+/*
+ WideImage_for_xoops
+ By CHG-WEB
+ 2012/04/08
+ Cédric MONTUY (montuy337513 / black_beard)
+ Original author : Gaspar Kozak
+*/
+if (!defined('XOOPS_ROOT_PATH')) {
+ die("XOOPS root path not defined");
+}
+class WideImage_Operation_CopyChannelsPalette{
+ function execute($img, $channels){
+ $blank = array('red' => 0, 'green' => 0, 'blue' => 0);
+ if (isset($channels['alpha']))
+ unset($channels['alpha']);
+ $width = $img->getWidth();
+ $height = $img->getHeight();
+ $copy = WideImage_PaletteImage::create($width, $height);
+ if ($img->isTransparent()){
+ $otci = $img->getTransparentColor();
+ $TRGB = $img->getColorRGB($otci);
+ $tci = $copy->allocateColor($TRGB);
+ }else{
+ $otci = NULL;
+ $tci = NULL;
+ }
+ for ($x = 0; $x < $width; $x++)
+ for ($y = 0; $y < $height; $y++){
+ $ci = $img->getColorAt($x, $y);
+ if ($ci === $otci){
+ $copy->setColorAt($x, $y, $tci);
+ continue;
+ }
+ $RGB = $img->getColorRGB($ci);
+ $newRGB = $blank;
+ foreach ($channels as $channel)
+ $newRGB[$channel] = $RGB[$channel];
+ $color = $copy->getExactColor($newRGB);
+ if ($color == -1)
+ ...
[truncated message content] |