To add a feature to a recent project, the user is wearing a device that captures the location and physical condition of the person and displays the data on the map. It seems like a good idea, but now there is no such device AH (pit daddy), can only simulate the data. And with the data to show more people on the map, also need a different icon, the initial idea is to use the user's number to identify. Make it look the same (this is the effect of the finish).
PHP is a little more familiar with, it is done with PHP,
Need to prepare a picture, from the Internet, the appropriate size of the reduction, and then began to use the program to generate the "
1, first need to get a picture resources
$im = imagecreatefrompng (' your.png ');
The parameter is the picture address that you prepare, because our picture is the PNG format, the PNG picture background is transparent, therefore all uses it. There are other functions, imagecreatefromjpeg, imagecreatefromgif and so on.
2, assign a color, here is white, the last three parameters is the value of RGB.
$color = imagecolorallocate ($im, 255, 255, 255);
3, write on the picture.
Imagettftext ($im$color, ' Monaco.ttf ', ' 10 ');
The parameters are: Picture resource, font size, text tilt, text position x, text position y, color, font file, text content. Where the text position is relative to the upper-left corner of the picture.
4. Output
Imagepng ($im);
If the second argument is omitted, the picture is exported to the browser. The second parameter is the storage location.
After doing this, I found that, wow, the picture has a background, we want to be transparent, on-line search, there is such a function:
Imagesavealpha ($imtrue);
So there's no background, it's transparent.
The complete code is as follows:
$im = imagecreatefrompng (' your.png '); Imagesavealpha ($imtrue); $color = imagecolorallocate ($im, 255, 255, 255); Imagettftext ($im$color , ' Monaco.ttf ', ' ten'); Imagepng ($im);
If you want to get more than one, you can cycle, then adjust the text position, output, look at my: