Question

In another question I saw some source, that would export an image into .gd or .gd2 format and then read raw pixel color data from the generated source.

Is this possible? Where can I find more information about these formats, or any other, that generates a raw pixel color data sequence of some sort?

My final goal is quite simple actually. I would like to read the color data of all pixels of an image (say 1000px by 1000px), without having to call imagecolorat a gazillion times :)

Was it helpful?

Solution

It's certainly possible. I've used the technique in a project. What the code does is add alpha channel information from a separate to an image. Something dead simple, but would be insanely slow using imagecolorat() and imagesetpixel().

The data is a read bear to work with. The image is divided into tiles, so getting the pixel at a given set of coordinates is a little tricky.

The information about the format came entirely from looking at the source code. I don't believe there's any other documentation.

The difficulty of directly manipulating pixels in standard PHP was the motivation behind the creation of the QB extension. It lets you do this kind of work at much more reasonable speed. Normalization of pixels into floating point vectors also simplifies calculation a great deal. Might be worth your while to look into.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top