On 8/26/05, Joe Van Dyk <joevandyk / gmail.com> wrote:
> On 8/26/05, Joe Van Dyk <joevandyk / gmail.com> wrote:
> > On 8/26/05, Brian Schr?der <ruby.brian / gmail.com> wrote:
> > > On 26/08/05, Joe Van Dyk <joevandyk / gmail.com> wrote:
> > > > I'm trying to set the pixels of an image:
> > > >
> > > > require 'RMagick'
> > > >
> > > > width = 512
> > > > height = 256
> > > >
> > > > image = Magick::Image.new width, height
> > > >
> > > > width.times do |x|
> > > >   height.times do |y|
> > > >     pixel = Magick::Pixel.new rand(256), rand(256), rand(256)
> > > >     image.pixel_color x, y, pixel
> > > >   end
> > > > end
> > > >
> > > > image.write ARGV.shift
> > > >
> > > > But the resulting image is all black.  Why?
> > > >
> > > >
> > >
> > > Use Magick::MaxRGB+1 instead of 256. RGB Values range from 0...2**16.
> > > And be shure to check out the View funktionality.
> > >
> > > regards,
> > >
> > > Brian
> >
> > Hm.  I'm reading in from a file that has a bunch of RGB values from 0
> > to 256.  So how can I set the pixel color of each pixel with that
> > data?
> 
> I'm starting to lose my mind now.
> 
> % ls
> test.rb
> 
> % cat test.rb
> 
> require 'RMagick'
> 
> file = ARGV.shift
> 
> width = 512
> height = 256
> 
> image = Magick::Image.new width, height
> 
> width.times do |x|
>   height.times do |y|
>     pixel = Magick::Pixel.new rand(6550), rand(65000), rand(64000)
>     image.pixel_color x, y, pixel
>   end
> end
> 
> image.write file
> 
> 
> % touch temp.jpg
> 
> % ls
> temp.jpg  test.rb
> 
> % rm temp.jpg
> 
> % ls
> test.rb
> 
> % ruby test.rb temp.jpg
> 
> % ls
> test.rb
> 
> % SCREW YOU
> SCREW: Command not found.
> 
> 
> Why isn't it writing the image any more?  Argh.  I swear stuff like
> this was working before.

Hm, I'm starting to think there's something wrong with my magick
installation.  :(