Re: class proposal: Image_Barcode
| From: | rocha at i-node dot com dot br | Date: | Thu, 28 Nov 2002 19:28:49 +0000 |
| Subject: | Re: class proposal: Image_Barcode | ||
| References: | 1 2 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-11235@lists.php.net to get a copy of this message | ||
Hi,
Had work in that problem some time ago, bellow is a snipped of the code to
create a HTML image sequence for Interleaved 2o5, no need do gd lib:
$bar = array (
"w" => "<img src=\"/imagens/b.gif\" width=3
height=50>",
"n" => "<img src=\"/imagens/b.gif\" width=1
height=50>"
);
$space = array (
"w" => "<img src=\"/imagens/w.gif\" width=3
height=50>",
"n" => "<img src=\"/imagens/w.gif\" width=1
height=50>"
);
function barrCode($numero) {
global $bar, $space;
$l25 = array(
"0" => "nnwwn",
"1" => "wnnnw",
"2" => "nwnnw",
"3" => "wwnnn",
"4" => "nnwnw",
"5" => "wnwnn",
"6" => "nwwnn",
"7" => "nnnww",
"8" => "wnnwn",
"9" => "nwnwn"
);
$barra = $bar[n] . $space[n] . $bar[n] . $space[n];
$stop = $bar[w] . $space[n] . $bar[n];
for ($i = 0; $i < strlen ($numero); $i += 2) {
$code = substr ($numero, $i, 2);
$first = substr ($code, 0, 1);
$second = substr ($code, 1, 1);
$seqBar = $l25[$first];
$seqSpace = $l25[$second];
for ($j = 0; $j < 5; $j++) {
$b = substr ($seqBar, $j, 1);
$s = substr ($seqSpace, $j, 1);
$barra .= $bar[$b] . $space[$s];
}
}
$barra .= $stop;
return $barra;
}
b.gif, and w.gif are black, and white gif pixels.
S.Rocha
PS.: +1 here too ;)
Citando Robin Johnson <robbat2@orbis-terrarum.net>:
> [Resend, because I forgot to copy pear-dev on my mail]
> On Wed, Nov 27, 2002 at 07:53:20PM -0200, Marcelo Subtil Marcal wrote:
> > Hi all,
> >
> > I have made a class that outputs a Interleaved 2 of 5 barcode of a
> > string. This class uses gd functions and the generated image can
> > be any of gd supported image types.
> >
> > New barcode types can be added easely. I'm working on Code 39 now.
> >
> > The code can be found at:
> > http://jason.unleashed.com.br/Image_Barcode/
> >
> >
> > The test script can be foud at:
> >
>
> http://jason.unleashed.com.br/Image_Barcode/test/barcode_test.php?
num=987654321
> >
> > Change num to any NUMBER you want.
> >
> > I'm thinking about putting it at Image/Barcode.
> >
> > Any votes / comments?
> +1 from me definetly.
>
> Feature requests/modifications:
> Allow user specified heights/widths for barcodes, as I find that the
> Int2of5 barcode displayed on my 2048x1782 monitor at work is too small
> to be seen.
>
> Looking at how it's programmed, I do have a further suggestion of
> abstraction.
>
> Basically all 1D barcodes are a set of lines and spaces. Instead of
> making each barcode sub-class use the GD functions explicitly, what
> about moving that stuff to the main barcode class, and let each barcode
> type just make calls in the main code to add spaces or lines of various
> widths?
>
> Comments:
> If nobody else beats me to it, I'll write up Codabar and Code 11
> routines, as those would be very handy for a job I'm working on
> presently.
>
> For anybody that wants to support specific types of barcodes, take a
> look at this page:
> http://www.makebarcode.com/specs/speclist.html
>
> I'll try out some of the generated barcodes with a scanner tommorow,
> just to see how reliable they are so far.
>
> --
> Robin Hugh Johnson
> E-Mail : robbat2@orbis-terrarum.net
> Home Page : http://www.orbis-terrarum.net/?l=people.robbat2
> ICQ# : 30269588 or 41961639
> GnuPG FP : 11AC BA4F 4778 E3F6 E4ED F38E B27B 944E 3488 4E85
>
>
>
> --
> PEAR Development Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/