Re: Re: Better way to store data in memory?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 7/23/07, Dan <frozendice@xxxxxxxxx> wrote:
Is there nothing like streams or a data type that's meant to hold lots of
binary data in PHP?

introduced back in php4; every time you call include, youre invoking an
underlying stream functions <http://www.php.net/manual/en/ref.stream.php>.

the big feature is you can define custom wrappers and filters.  also various
streams can be chained together
to process data.  i havent worked with them directly, but these functions
are supposedly considered optimal
when dealing with large files because the data can be buffered.
also, you should check out the functions
pack <http://www.php.net/manual/en/function.pack.php>
unpack <http://www.php.net/manual/en/function.unpack.php>
these are designed for direct manipulation of binary data.  i have never
worked with modification of image
files within code except to resize them w/ gd, so this is getting out of my
experience, but im pretty confident
these tools may be of some help.

-nathan

On 7/23/07, Dan <frozendice@xxxxxxxxx> wrote:

Is there nothing like streams or a data type that's meant to hold lots of
binary data in PHP?

- Dan

"Richard Davey" <rich@xxxxxxxxxxxxx> wrote in message
news:859866741.20070723175000@xxxxxxxxxxxxxxxx
> Hi php-general collective,
>
> I'm building up some image data in my PHP script (ready for output to
> the browser). Having to do some complex per pixel manipulation, which
> is fine - but I'm just wondering is there a quicker / more efficient
> way of storing the pixel data than in an array?
>
> At the moment I hold it in $array[$x][$y], which makes the drawing
> loop painless, but it's creating an array with 307,200 elements which
> is proving to be quite slow. As I'm only storing fixed width byte
> values is there an alternative method? For example the ability to
> read/write to a chunk of memory instead? (so I can read out whole
> strips of data rather than one by one?)
>
> I was looking at the Shared Memory functions, but that isn't exactly
> what I need (I don't want it shared, I want it process specific)
>
> Cheers,
>
> Rich
> --
> Zend Certified Engineer
> http://www.corephp.co.uk
>
> "Never trust a computer you can't throw out of a window"

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux