Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
T
test_h5
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
章建武
test_h5
Commits
96702231
Commit
96702231
authored
Dec 26, 2019
by
章建武
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dep
parent
46ac0580
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
40 deletions
+40
-40
IndexController.class.php
Application/Frontend/Controller/IndexController.class.php
+40
-40
No files found.
Application/Frontend/Controller/IndexController.class.php
View file @
96702231
...
...
@@ -128,46 +128,46 @@ class IndexController extends Controller
}
//圆图
public
function
yuan_img
(
$user_pic
,
$num
){
$ext
=
pathinfo
(
$user_pic
);
$src_img
=
null
;
switch
(
$ext
[
'extension'
])
{
case
'jpg'
:
$src_img
=
imagecreatefromjpeg
(
$user_pic
);
break
;
case
'png'
:
$src_img
=
imagecreatefrompng
(
$user_pic
);
break
;
}
$wh
=
getimagesize
(
$user_pic
);
$w
=
$wh
[
0
];
$h
=
$wh
[
1
];
$w
=
min
(
$w
,
$h
);
$h
=
$w
;
$img
=
imagecreatetruecolor
(
$w
,
$h
);
imagesavealpha
(
$img
,
true
);
//拾取一个完全透明的颜色,最后一个参数127为全透明
$bg
=
imagecolorallocatealpha
(
$img
,
255
,
255
,
255
,
127
);
imagefill
(
$img
,
0
,
0
,
$bg
);
$r
=
$w
/
2
;
//圆半径
$y_x
=
$r
;
//圆心X坐标
$y_y
=
$r
;
//圆心Y坐标
for
(
$x
=
0
;
$x
<
$w
;
$x
++
)
{
for
(
$y
=
0
;
$y
<
$h
;
$y
++
)
{
$rgbColor
=
imagecolorat
(
$src_img
,
$x
,
$y
);
if
((((
$x
-
$r
)
*
(
$x
-
$r
)
+
(
$y
-
$r
)
*
(
$y
-
$r
))
<
(
$r
*
$r
)))
{
imagesetpixel
(
$img
,
$x
,
$y
,
$rgbColor
);
}
}
}
$path
=
"H5/pimg/"
;
if
(
!
is_dir
(
$path
)){
mkdir
(
$path
,
0777
,
true
);
}
imagepng
(
$img
,
$path
.
$num
.
'.png'
);
}
//
public function yuan_img($user_pic,$num){
//
$ext = pathinfo($user_pic);
//
$src_img = null;
//
switch ($ext['extension']) {
//
case 'jpg':
//
$src_img = imagecreatefromjpeg($user_pic);
//
break;
//
case 'png':
//
$src_img = imagecreatefrompng($user_pic);
//
break;
//
}
//
$wh = getimagesize($user_pic);
//
$w = $wh[0];
//
$h = $wh[1];
//
$w = min($w, $h);
//
$h = $w;
//
$img = imagecreatetruecolor($w, $h);
//
imagesavealpha($img, true);
//
//拾取一个完全透明的颜色,最后一个参数127为全透明
//
$bg = imagecolorallocatealpha($img, 255, 255, 255, 127);
//
imagefill($img, 0, 0, $bg);
//
$r = $w / 2; //圆半径
//
$y_x = $r; //圆心X坐标
//
$y_y = $r; //圆心Y坐标
//
for ($x = 0; $x < $w; $x++) {
//
for ($y = 0; $y < $h; $y++) {
//
$rgbColor = imagecolorat($src_img, $x, $y);
//
if (((($x - $r) * ($x - $r) + ($y - $r) * ($y - $r)) < ($r * $r))) {
//
imagesetpixel($img, $x, $y, $rgbColor);
//
}
//
}
//
}
//
//
$path = "H5/pimg/";
//
if (!is_dir($path)){
//
mkdir($path,0777,true);
//
}
//
//
imagepng($img,$path.$num.'.png');
//
}
//缩略图
public
function
thumb
(
$user_pic
,
$num
){
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment