Page 273 - Open Soource Technologies 304.indd
P. 273

Unit 11: Graphics



            marks  the  limits  of  the  fill.  TheImageFillToBorder(  ) function lets you pass  the particular   Notes
            colour of the limits of the fill:
            ImageFill(image, x, y, color);
            ImageFillToBorder(image, x, y, border_color, color);



            Another thing that you may want to do  with your images is to rotate them. This  could  be
            helpful to do if you are trying to create a web style brochure, for example. The function used
            to accomplish this is called imagerotate and its syntax is:
            Imagerotate(image, angle, background color)



            The code in Example shows the black box image that was seen before; however it is rotated
            using this function by 45 degrees. The background color option, used to specify the color of the
            uncovered area after the image is rotated, has been set to 1 to show the contrast of the black
            and white colors. Be sure to play with this function to test the results before you put any of this
            image management code into full production.


                         Image rotation example.

            <?php
             $im = ImageCreate(200,200);

             $white = ImageColorAllocate($im,0xFF,0xFF,0xFF);
             $black = ImageColorAllocate($im,0x00,0x00,0x00);

             ImageFilledRectangle($im,50,50,150,150,$black);
             header(‘Content-Type: image/png’);
             $im_rotated = imagerotate($im, 45, 1);
             ImagePNG($im_rotated);

            ?>

                              Figure 11.6: Black Box Image Rotated 45 Degrees


























                                             LOVELY PROFESSIONAL UNIVERSITY                                   267
   268   269   270   271   272   273   274   275   276   277   278