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
Hide 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
...
@@ -128,46 +128,46 @@ class IndexController extends Controller
}
}
//圆图
//圆图
public
function
yuan_img
(
$user_pic
,
$num
){
//
public function yuan_img($user_pic,$num){
$ext
=
pathinfo
(
$user_pic
);
//
$ext = pathinfo($user_pic);
$src_img
=
null
;
//
$src_img = null;
switch
(
$ext
[
'extension'
])
{
//
switch ($ext['extension']) {
case
'jpg'
:
//
case 'jpg':
$src_img
=
imagecreatefromjpeg
(
$user_pic
);
//
$src_img = imagecreatefromjpeg($user_pic);
break
;
//
break;
case
'png'
:
//
case 'png':
$src_img
=
imagecreatefrompng
(
$user_pic
);
//
$src_img = imagecreatefrompng($user_pic);
break
;
//
break;
}
//
}
$wh
=
getimagesize
(
$user_pic
);
//
$wh = getimagesize($user_pic);
$w
=
$wh
[
0
];
//
$w = $wh[0];
$h
=
$wh
[
1
];
//
$h = $wh[1];
$w
=
min
(
$w
,
$h
);
//
$w = min($w, $h);
$h
=
$w
;
//
$h = $w;
$img
=
imagecreatetruecolor
(
$w
,
$h
);
//
$img = imagecreatetruecolor($w, $h);
imagesavealpha
(
$img
,
true
);
//
imagesavealpha($img, true);
//拾取一个完全透明的颜色,最后一个参数127为全透明
//
//拾取一个完全透明的颜色,最后一个参数127为全透明
$bg
=
imagecolorallocatealpha
(
$img
,
255
,
255
,
255
,
127
);
//
$bg = imagecolorallocatealpha($img, 255, 255, 255, 127);
imagefill
(
$img
,
0
,
0
,
$bg
);
//
imagefill($img, 0, 0, $bg);
$r
=
$w
/
2
;
//圆半径
//
$r = $w / 2; //圆半径
$y_x
=
$r
;
//圆心X坐标
//
$y_x = $r; //圆心X坐标
$y_y
=
$r
;
//圆心Y坐标
//
$y_y = $r; //圆心Y坐标
for
(
$x
=
0
;
$x
<
$w
;
$x
++
)
{
//
for ($x = 0; $x < $w; $x++) {
for
(
$y
=
0
;
$y
<
$h
;
$y
++
)
{
//
for ($y = 0; $y < $h; $y++) {
$rgbColor
=
imagecolorat
(
$src_img
,
$x
,
$y
);
//
$rgbColor = imagecolorat($src_img, $x, $y);
if
((((
$x
-
$r
)
*
(
$x
-
$r
)
+
(
$y
-
$r
)
*
(
$y
-
$r
))
<
(
$r
*
$r
)))
{
//
if (((($x - $r) * ($x - $r) + ($y - $r) * ($y - $r)) < ($r * $r))) {
imagesetpixel
(
$img
,
$x
,
$y
,
$rgbColor
);
//
imagesetpixel($img, $x, $y, $rgbColor);
}
//
}
}
//
}
}
//
}
//
$path
=
"H5/pimg/"
;
//
$path = "H5/pimg/";
if
(
!
is_dir
(
$path
)){
//
if (!is_dir($path)){
mkdir
(
$path
,
0777
,
true
);
//
mkdir($path,0777,true);
}
//
}
//
imagepng
(
$img
,
$path
.
$num
.
'.png'
);
//
imagepng($img,$path.$num.'.png');
}
//
}
//缩略图
//缩略图
public
function
thumb
(
$user_pic
,
$num
){
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