How do I echo a binary array (transparent pixel)

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

    How do I echo a binary array (transparent pixel)

    Hi,

    What am I doing wrong here? I want to display a transparent pixel...

    <?
    $transparent1x1 = array (71, 73, 70, 56, 57, 97, 1, 0, 1, 0, -128, 0,
    0, 0, 0, 0, 0, 0, 0, 33, -7, 4, 1, 0, 0, 0, 0, 44, 0, 0, 0, 0, 1, 0,
    1, 0, 0, 2, 2, 68, 1, 0, 59);
    header("Content-type: " . image_type_to_m ime_type (IMAGETYPE_GIF) );
    echo $transparent1x1 ;
    ?>
  • Cameron

    #2
    Re: How do I echo a binary array (transparent pixel)

    Leif Wessman wrote:[color=blue]
    > Hi,
    >
    > What am I doing wrong here? I want to display a transparent pixel...
    >
    > <?
    > $transparent1x1 = array (71, 73, 70, 56, 57, 97, 1, 0, 1, 0, -128, 0,
    > 0, 0, 0, 0, 0, 0, 0, 33, -7, 4, 1, 0, 0, 0, 0, 44, 0, 0, 0, 0, 1, 0,
    > 1, 0, 0, 2, 2, 68, 1, 0, 59);
    > header("Content-type: " . image_type_to_m ime_type (IMAGETYPE_GIF) );
    > echo $transparent1x1 ;
    > ?>[/color]


    Using echo on an array will just output the type which is "Array" you
    need to echo the values so...

    for ($i = 0; $i < count($transpar ent1x1); $i++)
    echo $trasnparent1x1[$i];

    N.B. I don't know if the above code will produce the desired effect for
    a pixel, I have never done anything like that.

    ~Cameron

    Comment

    • R. Rajesh Jeba Anbiah

      #3
      Re: How do I echo a binary array (transparent pixel)

      Cameron <foo@bar.invali d> wrote in message news:<bvnu9g$ld l$1@newsg3.svr. pol.co.uk>...[color=blue]
      > Leif Wessman wrote:[color=green]
      > > Hi,
      > >
      > > What am I doing wrong here? I want to display a transparent pixel...
      > >
      > > <?
      > > $transparent1x1 = array (71, 73, 70, 56, 57, 97, 1, 0, 1, 0, -128, 0,
      > > 0, 0, 0, 0, 0, 0, 0, 33, -7, 4, 1, 0, 0, 0, 0, 44, 0, 0, 0, 0, 1, 0,
      > > 1, 0, 0, 2, 2, 68, 1, 0, 59);
      > > header("Content-type: " . image_type_to_m ime_type (IMAGETYPE_GIF) );
      > > echo $transparent1x1 ;
      > > ?>[/color]
      >
      >
      > Using echo on an array will just output the type which is "Array" you
      > need to echo the values so...
      >
      > for ($i = 0; $i < count($transpar ent1x1); $i++)
      > echo $trasnparent1x1[$i];[/color]
      ^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^

      It should be echo chr($transparen t1x1[$i]) or printf("%c",
      $transparent1x1[$i]). Otherwise, echo will output ascii.

      --
      "Success = 10% sweat + 90% tears"
      Email: rrjanbiah-at-Y!com

      Comment

      Working...