php imageantialias

 更新时间:2016年11月25日 16:51  点击:2274

imageantialias
(PHP 4 >= 4.3.2, PHP 5)
描述
布尔imageantialias($sourc,$bool)
激活的行反走样快速绘制方法和有线多边形。它不支持阿尔法组件。它可以使用直接混合操作。但它只能在真彩色图像。

厚度和风格不支持。

使用透明背景颜色抗锯齿原语可以结束一些意想不到的结果。混合方法使用任何其他颜色的背景颜色。阿尔法组件的支持,缺乏不允许一个字母为基础的抗锯齿方法

图片
图像资源,通过创造的图像功能,如,一返回imagecreatetruecolor()。

启用
是否启用抗锯齿与否。

返回值
返回TRUE,成功或失败则返回FALSE

<?php
// Setup an anti-aliased image and a normal image
$aa = imagecreatetruecolor(400, 100);
$normal = imagecreatetruecolor(200, 100);

// Switch antialiasing on for one image
imageantialias($aa, true);

// Allocate colors
$red = imagecolorallocate($normal, 255, 0, 0);
$red_aa = imagecolorallocate($aa, 255, 0, 0);

// Draw two lines, one with AA enabled
imageline($normal, 0, 0, 200, 100, $red);
imageline($aa, 0, 0, 200, 100, $red_aa);

// Merge the two images side by side for output (AA: left, Normal: Right)
imagecopymerge($aa, $normal, 200, 0, 0, 0, 200, 100, 100);

// Output image
header('Content-type: image/png');

imagepng($aa);
imagedestroy($aa);
imagedestroy($normal);
?>

php imagecolorallocate

imagecolorallocate - 分配一个彩色的图像

int imagecolorallocate ( resource $image , int $red , int $green , int $blue

)

返回一个颜色标识代表给定的RGB成分组成的颜色。

imagecolorallocate()必须被调用来创建每个颜色,将在由形象代表的图像中使用。

注:第一次调用imagecolorallocate()填补了调色板背景颜色的图像 - 图像创建使

用imagecreate()。

图片
图像资源,通过创造的图像功能,如,一返回imagecreatetruecolor()。

红色
红色分量的价值。

绿色
价值的绿色成分。

蓝色
蓝色成分的价值。

这些参数是介于0和255之间或0x00和0xFF十六进制整数。

报告错误返回值
阿色标识或FALSE如果分配失败。


<?php

$im = imagecreate(100, 100);

// sets background to red
$background = imagecolorallocate($im, 255, 0, 0);

// sets some colors
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);

// hexadecimal way
$white = imagecolorallocate($im, 0xFF, 0xFF, 0xFF);
$black = imagecolorallocate($im, 0x00, 0x00, 0x00);

?>
这里有一个非常简单的函数,基本上是相同imagecolorallocate(),而无需只有一个

图像资源工作。

<?php
function createcolor($r, $g, $b) {
  return hexdec(str_pad(dechex($r), 2, 0, STR_PAD_LEFT).str_pad(dechex($g),

2, 0, STR_PAD_LEFT).str_pad(dechex($b), 2, 0, STR_PAD_LEFT));
}

/ *正如前面所说的,这个函数不完全一样的事情作为imagecolorallocate(),而不

需要一个图像资源。这意味着,下面的两个区块中的代码的结果完全相同的事情:* /

$color = colorcreate(105, 199, 204);

//Block 2
$img = imagecreatetruecolor(100, 100); //the arguments here don't really

matter
$color = imagecolorallocate($img, 105, 199, 204);
imagedestroy($img);
?>

imagealphablending
(PHP 4中“= 4.0.6,PHP 5中)

imagealphablending - 设置图像混合模式

报告错误描述
布尔imagealphablending($img,$blendMode $)
imagealphablending()两对真彩色图像绘制不同的模式允许。在混合模式下,供应的,如imagesetpixel所有绘图功能,颜色的alpha通道组件()决定了底层的颜色应允许穿透。因此,广东在混合自动绘图与现有的色点的颜色,在图像存储的结果。由此产生的像素是不透明的。在非混合模式,绘图颜色复制其字面alpha通道信息,替换目标像素。混合模式用时没有对调色板图像绘图。

报告错误参数

图片
图像资源,通过创造的图像功能,如,一返回imagecreatetruecolor()。

将对blendMode
是否启用了混合模式或不。默认为FALSE。


报告错误返回值
返回TRUE,成功或失败则返回FALSE。

报告错误的例子
例子1 imagealphablending()使用示例

<?php
// Create image
$im = imagecreatetruecolor(100, 100);

// Set alphablending to on
imagealphablending($im, true);

// Draw a square
imagefilledrectangle($im, 30, 30, 70, 70, imagecolorallocate($im, 255, 0, 0));

// Output
header('Content-type: image/png');

imagepng($im);
imagedestroy($im);
?>

php imagecreatetruecolor创建高清图片函数
imagecreatetruecolor()返回一个图像标识符代表指定大小的黑色形象。

根据你的PHP和GD版本中函数定义与否。对于PHP 4.0.6通过4.1.x这个函数总是存在的

,如果广东模块加载,但它要求GD2的情况下被安装了PHP将发出一个致命错误并退出。

用PHP 4.2.x版这种行为是不同的人发出警告,而不是一个错误。其他版本只定义此功

能,

看看实例

<?php
header ('Content-type: image/png');
$im = @imagecreatetruecolor(120, 20)
      or die('Cannot Initialize new GD image stream');
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5,  'A Simple Text String', $text_color);
imagepng($im);
imagedestroy($im);
?>


我提出这方面合作 - 结合一些例子,然后动态生成的文本。但是,与此设置,我能得

到透明背景的工作也。

<?php
// Set the content-type

header('Content-type: image/png');

// Create the image
$im = imagecreatetruecolor(175, 15);
imagesavealpha($im, true);

// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 150, 25, $black);
$trans_colour = imagecolorallocatealpha($im, 0, 0, 0, 127);
imagefill($im, 0, 0, $trans_colour);

// The text to draw
$text = $_GET['text'];
// Replace path by your own font path
$font = 'catriel regular.ttf';

// Add some shadow to the text
imagettftext($im, 9, 0, 13, 16, $black, $font, $text);

// Add the text
imagettftext($im, 9, 0, 12, 15, $white, $font, $text);

// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>

php imagecopyresized实例

描述
布尔imagecopyresized($ dst_image,$ src_image,$ dst_x,$ dst_y,$ src_x,$

src_y,$ dst_w,$ dst_h,$ src_w,$ src_h)
imagecopyresized()拷贝一个长方形的部分图像到另一个图像。 dst_image的目标图

像,src_image是源图像的标识符。

换句话说,imagecopyresized()将于src_w的宽度和高度src_h src_image的位置

(src_x,src_y),并将其放置在dst_w的宽度和高度dst_h dst_image矩形区域,它是

在位置的矩形区域(dst_x,dst_y)。

如果源和目标坐标,宽度和高度不同,适当的伸展或收缩的图像片段将进行。坐标是指

在左上角。该功能可用于复制的图像在同一地区(如dst_image是相同的src_image),

但如果区域重叠的结果将不可预测。


参数说明:

dst_im
目标图像链接的资源。

src_im
源图像链接的资源。

dst_x
X坐标的目的地。

dst_y
y坐标目的地。

src_x
X坐标的源点。

src_y
y坐标源点。

dst_w
目的地宽度。

dst_h
目标高度。

src_w
源宽度。

src_h
源高度。

来看看imagecopyresized函数实例

<?php
// File and new size
$filename = 'test.jpg';
$percent = 0.5;

// Content type
header('Content-type: image/jpeg');

// Get new sizes
list($width, $height) = getimagesize($filename);
$newwidth = $width * $percent;
$newheight = $height * $percent;

// Load
$thumb = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefromjpeg($filename);

// Resize
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width,

$height);

// Output
imagejpeg($thumb);
?>

[!--infotagslink--]

相关文章

  • 源码分析系列之json_encode()如何转化一个对象

    这篇文章主要介绍了源码分析系列之json_encode()如何转化一个对象,对json_encode()感兴趣的同学,可以参考下...2021-04-22
  • php中去除文字内容中所有html代码

    PHP去除html、css样式、js格式的方法很多,但发现,它们基本都有一个弊端:空格往往清除不了 经过不断的研究,最终找到了一个理想的去除html包括空格css样式、js 的PHP函数。...2013-08-02
  • index.php怎么打开?如何打开index.php?

    index.php怎么打开?初学者可能不知道如何打开index.php,不会的同学可以参考一下本篇教程 打开编辑:右键->打开方式->经文本方式打开打开运行:首先你要有个支持运行PH...2017-07-06
  • PHP中func_get_args(),func_get_arg(),func_num_args()的区别

    复制代码 代码如下:<?php function jb51(){ print_r(func_get_args()); echo "<br>"; echo func_get_arg(1); echo "<br>"; echo func_num_args(); } jb51("www","j...2013-10-04
  • PHP编程 SSO详细介绍及简单实例

    这篇文章主要介绍了PHP编程 SSO详细介绍及简单实例的相关资料,这里介绍了三种模式跨子域单点登陆、完全跨单点域登陆、站群共享身份认证,需要的朋友可以参考下...2017-01-25
  • PHP实现创建以太坊钱包转账等功能

    这篇文章主要介绍了PHP实现创建以太坊钱包转账等功能,对以太坊感兴趣的同学,可以参考下...2021-04-20
  • php微信公众账号开发之五个坑(二)

    这篇文章主要为大家详细介绍了php微信公众账号开发之五个坑,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2016-10-02
  • ThinkPHP使用心得分享-ThinkPHP + Ajax 实现2级联动下拉菜单

    首先是数据库的设计。分类表叫cate.我做的是分类数据的二级联动,数据需要的字段有:id,name(中文名),pid(父id). 父id的设置: 若数据没有上一级,则父id为0,若有上级,则父id为上一级的id。数据库有内容后,就可以开始写代码,进...2014-05-31
  • PHP如何通过date() 函数格式化显示时间

    这篇文章主要介绍了PHP如何通过date() 函数格式化显示时间,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下...2020-11-13
  • 基于JS2Image实现圣诞树代码

    马上圣诞节了,作为一名程序猿,如何体现自己独特的过节风格,如何在朋友圈发一张专属自己的祝福照片我觉得很有必要,你们说是不是...2015-12-25
  • PHP+jQuery+Ajax实现多图片上传效果

    今天我给大家分享的是在不刷新页面的前提下,使用PHP+jQuery+Ajax实现多图片上传的效果。用户只需要点击选择要上传的图片,然后图片自动上传到服务器上并展示在页面上。...2015-03-15
  • 微信小程序 Image API实例详解

    这篇文章主要介绍了微信小程序 Image API实例详解的相关资料,需要的朋友可以参考下...2016-10-02
  • golang与php实现计算两个经纬度之间距离的方法

    这篇文章主要介绍了golang与php实现计算两个经纬度之间距离的方法,结合实例形式对比分析了Go语言与php进行经纬度计算的相关数学运算技巧,需要的朋友可以参考下...2016-07-29
  • PHP如何使用cURL实现Get和Post请求

    这篇文章主要介绍了PHP如何使用cURL实现Get和Post请求,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下...2020-07-11
  • PHP正则表达式过滤html标签属性(DEMO)

    这篇文章主要介绍了PHP正则表达式过滤html标签属性的相关内容,实用性非常,感兴趣的朋友参考下吧...2016-05-06
  • 谈谈PHP中相对路径的问题与绝对路径的使用

    经常看到有人踩在了PHP路径的坑上面了,感觉有必要来说说PHP中相对路径的一些坑,以及PHP中绝对路径的使用,下面一起来看看。 ...2016-08-24
  • php构造方法中析构方法在继承中的表现

    这篇文章主要为大家详细介绍了php构造方法中析构方法在继承中的表现,感兴趣的小伙伴们可以参考一下...2016-04-15
  • thinkPHP中多维数组的遍历方法

    这篇文章主要介绍了thinkPHP中多维数组的遍历方法,以简单实例形式分析了thinkPHP中foreach语句的使用技巧,需要的朋友可以参考下...2016-01-12
  • C# byte数组与Image相互转换的方法

    这篇文章介绍了C# byte数组与Image相互转换的方法,有需要的朋友可以参考一下...2020-06-25
  • php有序列表或数组中删除指定的值的实现代码

    这篇文章主要介绍了php有序列表或数组中删除指定的值的实现代码,删除给定的值之后,得到一个新的有序列表,长度-1,下面是具体的实现方法...2021-08-22