On Wed, Aug 4, 2010 at 6:50 AM, mark.t.macdon...@googlemail.com <
> Is there a way I can do this without creating a Pixel pointer?
> Something like this (which doesn't compile):
That said, you may find that this is a pretty inefficient way to represent
image data. Every pixel will allocate a separate object, and will take up
at least eight bytes on the wire (ten if alpha is set, more if any of the
values are >= 128): each value has a 1-byte tag, and each pixel has another
one-byte tag and one-byte message size.
I'd advise packing all of the values into a single array. One way you could
do this is using a packed array:
repeated int32 pixels = 4 [packed = true];
Every three (or four) elements in this "pixels" array would map to the RGB
(RGBA) components for one pixel.
This is still somewhat inefficient in that, assuming values are evenly
distributed in the range [0,256), half of the components will take two bytes
instead of one (since numbers >= 128 take two bytes).
Therefore, you might instead want:
required bytes pixels = 4;
where each byte is one component, so each three/four bytes is one pixel.
Or you might try:
repeated fixed32 pixels = 4 [packed = true];
Here, each element is a whole pixel, with individual bits mapping to the
You received this message because you are subscribed to the Google Groups
"Protocol Buffers" group.
To post to this group, send email to proto...@googlegroups.com.
To unsubscribe from this group, send email to
For more options, visit this group at