From: Alwin Blok Date: 2004-03-15T06:50:49+09:00 Subject: Re: binary data On 2-mrt-04, at 5:49, daz wrote: > Like Neil said ... > > > File.open('tbinary.dat', 'wb') do |fb| > fb.putc 0b11011011 > fb.putc 255 > fb.putc 0xAB > fb.putc 0x42 > end > > ## See what happened ... > File.open('tbinary.dat', 'rb') do |fb| > bd = fb.read > puts bd.unpack('H*') > end > > > #-> dbffab42 > > > daz I was playing wih the framebuffer device, using pack, I was able to get the bits where I wanted, but It's not handy when you want gradients and other fancy stuff When I use File.open('/dev/fb0','w') do |fb| (800*600).times do fb.putc 0b0111110000000000 end end I get half my screen filled, Which is obvious since putc is short for putchar (i assume), hence 8bits (the screen is 16 bits color) So my real question is: What command do I use to put an arbitrary amount of bits? I can think of some ways, but I hate it when it feels like a workaround. Thanks -Alwin