Ejemplo n.º 1
0
 public function load($param)
 {
     $key = $this->build_key(__CLASS__, $param);
     $GLOBALS['fcache']->set_dir(APP_ROOT_PATH . "public/runtime/data/" . __CLASS__ . "/");
     $image_str = $GLOBALS['fcache']->get($key);
     if ($image_str === false) {
         $img = $param['img'];
         $img_path = str_replace("./", SITE_DOMAIN . APP_ROOT . "/", $img);
         require_once APP_ROOT_PATH . "system/utils/es_image.php";
         $imagec = new es_image();
         $info = $imagec->getImageInfo($img);
         if ($info['mime'] == 'image/png') {
             $image_str = "<span style='display:inline-block; width:" . intval($info['width']) . "px; height:" . intval($info['height']) . "px; background:url(" . $img_path . ") no-repeat; _filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=" . $img_path . ", sizingMethod=scale);_background-image:none;'></span>";
         } else {
             $image_str = "<img src='" . $img_path . "' width='" . intval($info['width']) . "' height='" . intval($info['height']) . "' />";
         }
         $GLOBALS['fcache']->set_dir(APP_ROOT_PATH . "public/runtime/data/" . __CLASS__ . "/");
         $GLOBALS['fcache']->set("PAGE_IMAGE_" . $img, $image_str);
     }
     return $image_str;
 }
Ejemplo n.º 2
0
 /**
 +----------------------------------------------------------
 * 把图像转换成字符显示
 +----------------------------------------------------------
 * @static
 * @access public
 +----------------------------------------------------------
 * @param string $es_image  要显示的图像
 * @param string $type  图像类型,默认自动获取
 +----------------------------------------------------------
 * @return string
 +----------------------------------------------------------
 */
 static function showASCIIImg($image, $string = '', $type = '')
 {
     $info = es_image::getImageInfo($image);
     if ($info !== false) {
         $type = empty($type) ? $info['type'] : $type;
         unset($info);
         // 载入原图
         $createFun = 'ImageCreateFrom' . ($type == 'jpg' ? 'jpeg' : $type);
         $im = $createFun($image);
         $dx = imagesx($im);
         $dy = imagesy($im);
         $i = 0;
         $out = '<span style="padding:0px;margin:0;line-height:100%;font-size:1px;">';
         set_time_limit(0);
         for ($y = 0; $y < $dy; $y++) {
             for ($x = 0; $x < $dx; $x++) {
                 $col = imagecolorat($im, $x, $y);
                 $rgb = imagecolorsforindex($im, $col);
                 $str = empty($string) ? '*' : $string[$i++];
                 $out .= sprintf('<span style="margin:0px;color:#%02x%02x%02x">' . $str . '</span>', $rgb['red'], $rgb['green'], $rgb['blue']);
             }
             $out .= "<br>\n";
         }
         $out .= '</span>';
         imagedestroy($im);
         return $out;
     }
     return false;
 }
Ejemplo n.º 3
0
function get_parse_expres($cnt)
{
    $expression_replace_array = $GLOBALS['cache']->get("MOBILE_EXPRESSION_REPLACE_ARRAY");
    if ($expression_replace_array === false) {
        require_once APP_ROOT_PATH . "system/utils/es_image.php";
        $result = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "expression");
        foreach ($result as $item) {
            $img_info = es_image::getImageInfo(APP_ROOT_PATH . "public/expression/" . $item['type'] . "/" . $item['filename']);
            $expression_replace_array[$item['emotion']] = array("key" => $item['emotion'], "value" => get_abs_img_root("./public/expression/" . $item['type'] . "/" . $item['filename']), "width" => $img_info['width'], "height" => $img_info['height']);
        }
        $GLOBALS['cache']->set("MOBILE_EXPRESSION_REPLACE_ARRAY", $expression_replace_array);
    }
    $result = array();
    if (preg_match_all("/\\[[^\\]]+\\]/i", $cnt, $matches)) {
        $matches[0] = array_unique($matches[0]);
        foreach ($matches[0] as $key) {
            if (!empty($expression_replace_array[$key])) {
                $result[] = $expression_replace_array[$key];
            }
        }
    }
    $result[] = $expression_replace_array['[爱心]'];
    return $result;
}