From: Robert Klemme Date: 2008-06-15T21:59:20+09:00 Subject: Re: Binary string packing/unpacking issues On 15.06.2008 12:00, Lucas L. wrote: > Robert Klemme wrote: >> It's the bitwise OR operator. > I don't really know why he uses it though. > > Can you post what "p >> your_pixbuf.pixels" and "p your_pixbuf.pixels.class" print? > > Now we're getting somewhere. I was using puts to print pixels, and all I > got was a bunch of question marks. p returns a massive String > (pixels.class shows String). The string itself is uncompressed pixel > data, a byte per channel of RGBA. The output is a massive string of > "\000\000\000\000\000\000\000\000..." with "\377" where a pixel is > drawn, which I'm assumming is 0xFF in the alpha channel (why is \377 > 0xFF?). > > However, when I tried >> pixels[pixels.length-1] = '\377' >> p pixels > There was no change. irb#1(main):006:0> "\377" => "\377" irb#1(main):007:0> "\377".length => 1 irb#1(main):008:0> '\377' => "\\377" irb#1(main):009:0> '\377'.length => 4 irb#1(main):010:0> Notice something? I agree with Paul, you have trouble with the basics. If you try things out on a smaller scale in IRB you'll probably see more easily how everything works. Kind regards robert