本文整理汇总了PHP中TCPDF_STATIC::rfread方法的典型用法代码示例。如果您正苦于以下问题:PHP TCPDF_STATIC::rfread方法的具体用法?PHP TCPDF_STATIC::rfread怎么用?PHP TCPDF_STATIC::rfread使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TCPDF_STATIC
的用法示例。
在下文中一共展示了TCPDF_STATIC::rfread方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _parsepng
/**
* Extract info from a PNG file without using the GD library.
* @param $file (string) image file to parse
* @return array structure containing the image data
* @public static
*/
public static function _parsepng($file)
{
$f = @fopen($file, 'rb');
if ($f === false) {
// Can't open image file
return false;
}
//Check signature
if (fread($f, 8) != chr(137) . 'PNG' . chr(13) . chr(10) . chr(26) . chr(10)) {
// Not a PNG file
return false;
}
//Read header chunk
fread($f, 4);
if (fread($f, 4) != 'IHDR') {
//Incorrect PNG file
return false;
}
$w = TCPDF_STATIC::_freadint($f);
$h = TCPDF_STATIC::_freadint($f);
$bpc = ord(fread($f, 1));
$ct = ord(fread($f, 1));
if ($ct == 0) {
$colspace = 'DeviceGray';
} elseif ($ct == 2) {
$colspace = 'DeviceRGB';
} elseif ($ct == 3) {
$colspace = 'Indexed';
} else {
// alpha channel
fclose($f);
return 'pngalpha';
}
if (ord(fread($f, 1)) != 0) {
// Unknown compression method
fclose($f);
return false;
}
if (ord(fread($f, 1)) != 0) {
// Unknown filter method
fclose($f);
return false;
}
if (ord(fread($f, 1)) != 0) {
// Interlacing not supported
fclose($f);
return false;
}
fread($f, 4);
$channels = $ct == 2 ? 3 : 1;
$parms = '/DecodeParms << /Predictor 15 /Colors ' . $channels . ' /BitsPerComponent ' . $bpc . ' /Columns ' . $w . ' >>';
//Scan chunks looking for palette, transparency and image data
$pal = '';
$trns = '';
$data = '';
$icc = false;
do {
$n = TCPDF_STATIC::_freadint($f);
$type = fread($f, 4);
if ($type == 'PLTE') {
// read palette
$pal = TCPDF_STATIC::rfread($f, $n);
fread($f, 4);
} elseif ($type == 'tRNS') {
// read transparency info
$t = TCPDF_STATIC::rfread($f, $n);
if ($ct == 0) {
// DeviceGray
$trns = array(ord($t[1]));
} elseif ($ct == 2) {
// DeviceRGB
$trns = array(ord($t[1]), ord($t[3]), ord($t[5]));
} else {
// Indexed
if ($n > 0) {
$trns = array();
for ($i = 0; $i < $n; ++$i) {
$trns[] = ord($t[$i]);
}
}
}
fread($f, 4);
} elseif ($type == 'IDAT') {
// read image data block
$data .= TCPDF_STATIC::rfread($f, $n);
fread($f, 4);
} elseif ($type == 'iCCP') {
// skip profile name
$len = 0;
while (ord(fread($f, 1)) != 0 and $len < 80) {
++$len;
}
// get compression method
if (ord(fread($f, 1)) != 0) {
//.........这里部分代码省略.........