ImageDashedLine problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sky2070

    ImageDashedLine problem

    <?php
    Header("Content-Type: image/png");
    $im = ImageCreate(100 , 100);
    // Allocate a background color and a drawing color for the image
    $black = ImageColorAlloc ate($im, 0, 0, 0);
    $white = ImageColorAlloc ate($im, 255, 255, 255);
    /* Now to draw a dashed line from the upper left corner to the
    lower right corner */
    ImageDashedLine ($im, 0, 0, 99, 99, $white);
    // Print and destroy the image
    Imagepng($im,"d ashed.png");
    ImageDestroy($i m);
    ?>


    no dashed line appear, i created the correct result with the folowing
    code
    but i does not understand why the imagedashedline does not work.


    $style = array ($black,$black, $black,$black,$ black,$white,$w hite,$white,$wh ite,$white);
    imagesetstyle ($im, $style);
    imageline ($im, 0, 0, 100, 100, IMG_COLOR_STYLE D);
  • Brian

    #2
    Re: ImageDashedLine problem

    Is there any reason you're not just doing it in CSS?

    img.imgbdr {
    border:2px dashed #000000;
    }

    <img src="picture.pn g" class="imgbdr">



    skywalker2070@h otmail.com (sky2070) wrote in
    news:e7f0b985.0 307132314.50874 3b7@posting.goo gle.com:
    [color=blue]
    > <?php
    > Header("Content-Type: image/png");
    > $im = ImageCreate(100 , 100);
    > // Allocate a background color and a drawing color for the image
    > $black = ImageColorAlloc ate($im, 0, 0, 0);
    > $white = ImageColorAlloc ate($im, 255, 255, 255);
    > /* Now to draw a dashed line from the upper left corner to the
    > lower right corner */
    > ImageDashedLine ($im, 0, 0, 99, 99, $white);
    > // Print and destroy the image
    > Imagepng($im,"d ashed.png");
    > ImageDestroy($i m);
    > ?>
    >
    >
    > no dashed line appear, i created the correct result with the folowing
    > code
    > but i does not understand why the imagedashedline does not work.
    >
    >
    > $style = array
    > ($black,$black, $black,$black,$ black,$white,$w hite,$white,$wh ite,$white)
    > ; imagesetstyle ($im, $style);
    > imageline ($im, 0, 0, 100, 100, IMG_COLOR_STYLE D);
    >[/color]

    Comment

    • sky2070

      #3
      Re: ImageDashedLine problem

      Brian <ThisIsNotMyRea l@ddress.com> wrote in message news:<Xns93B8B5 D315868nonenone com@24.28.95.15 8>...[color=blue]
      > Is there any reason you're not just doing it in CSS?
      >[/color]
      for now i just want learn php and find a solution in php

      Comment

      • 2metre

        #4
        Re: ImageDashedLine problem

        In this line
        Imagepng($im,"d ashed.png");
        You've specified a filename. As a result the image is output to the file and
        NOT to the browser.


        "sky2070" <skywalker2070@ hotmail.com> wrote in message
        news:e7f0b985.0 307132314.50874 3b7@posting.goo gle.com...[color=blue]
        > <?php
        > Header("Content-Type: image/png");
        > $im = ImageCreate(100 , 100);
        > // Allocate a background color and a drawing color for the image
        > $black = ImageColorAlloc ate($im, 0, 0, 0);
        > $white = ImageColorAlloc ate($im, 255, 255, 255);
        > /* Now to draw a dashed line from the upper left corner to the
        > lower right corner */
        > ImageDashedLine ($im, 0, 0, 99, 99, $white);
        > // Print and destroy the image
        > Imagepng($im,"d ashed.png");
        > ImageDestroy($i m);
        > ?>
        >
        >
        > no dashed line appear, i created the correct result with the folowing
        > code
        > but i does not understand why the imagedashedline does not work.
        >
        >
        > $style = array[/color]
        ($black,$black, $black,$black,$ black,$white,$w hite,$white,$wh ite,$white);[color=blue]
        > imagesetstyle ($im, $style);
        > imageline ($im, 0, 0, 100, 100, IMG_COLOR_STYLE D);[/color]


        Comment

        Working...