Draw char with color : Draw String « Graphics Image « PHP

Home
PHP
1.Chart
2.Class
3.Components
4.Cookie Session
5.Data Structure
6.Data Type
7.Date
8.Design Patterns
9.Development
10.DNS
11.Email
12.File Directory
13.Form
14.Functions
15.Graphics Image
16.HTML
17.Language Basics
18.Login Authentication
19.Math
20.MySQL Database
21.Network
22.Operator
23.PDF
24.Reflection
25.Statement
26.String
27.Utility Function
28.Web Services SOAP WSDL
29.XML
PHP » Graphics Image » Draw String 




Draw char with color


<html>
<body>
                              
<?php
    $img=ImageCreate(200,200);

    $bgcolor=ImageColorAllocate($img,200,200,200);
    $red=ImagecolorAllocate($img,255,0,0)
    $green=ImagecolorAllocate($img,0,255,0)
    $blue=ImagecolorAllocate($img,0,0,255)
    $grey=ImagecolorAllocate($img,50,50,50)
    $black=ImagecolorAllocate($img,0,0,0)
                                                            
    ImageChar($img,0,20,20,"S",$red);
    ImageChar($img,1,20,40,"S",$green);
    ImageChar($img,2,20,60,"S",$blue);
    ImageChar($img,3,20,80,"S",$grey);
    ImageChar($img,4,20,100,"S",$black);
    ImageChar($img,5,20,120,"S",$red);
                                                            
    ImageCharUp($img,020,160,"S",$red);
    ImageCharUp($img,140,160,"S",$green);
    ImageCharUp($img,260,160,"S",$blue);
    ImageCharUp($img,380,160,"S",$grey);
    ImageCharUp($img,4,100,160,"S",$black);
    ImageCharUp($img,5,120,160,"S",$red);
                                                            
    /*
    RGB Red = 0..255 , Green = 0..255 , Blue = 0..255.
     */
    ImageSetPixel($img,50,50,$pixelcolor);
    ImagePNG($img,"pic.png");
    ImageDestroy($img);

?>
<img src="pic.png" border=0>
</body>
</html>
           
       














Related examples in the same category
1.Paint string value with different colors and position
2.Draw string and fill rectangle
3.Using a Bounding Box to Center Text
4.Drawing a Square and a string
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.