From: Joe Van Dyk Date: 2005-08-27T07:50:11+09:00 Subject: Re: rmagick question On 8/26/05, Brian Schr�der wrote: > On 26/08/05, Joe Van Dyk 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. The following behavior is confusing to me. p rgb pixel = Magick::Pixel.new(*rgb) image.pixel_color(e, n, pixel) p image.pixel_color(e, n) p pixel This returns the following output: [2, 0, 0] red=65535, green=65535, blue=65535, opacity=0 red=2, green=0, blue=0, opacity=0 I create a new pixel, I set the image pixel to be that color, but the image pixel is still a different color.