Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Ruby - RMagick -- Python Challenge

Name: Anonymous 2012-03-19 0:59

sup /prog/,

I'm doing Python Challenge 7(http://www.pythonchallenge.com/pc/def/oxygen.html), and have it pretty much figured out, however I am having trouble with the RMagick library. I'm an experienced programmer, however I am new to Ruby. There is a hidden message encoded into the image, you can see it, it is the gray strip across the center. Each color corresponds to a hex number, which can be converted to an ascii character. However, when looping through each color, I get a bounds error at pixel 317(on the x axis), when the image is actually 629 pixels wide.

Here's the error I get:

 [10challenge7.rb:20:in `get_pixels': geometry (317x47+317+47) exceeds image bounds (RangeError)
from challenge7.rb:20:in `block in <main>'
from challenge7.rb:18:in `each'
from challenge7.rb:18:in `<main>'

Here's my code: http://pastebin.com/CAQs18Ri

Any help is very much appreciated, I just don't understand why it says I'm exceeding the image bounds when I'm not. I'm able to read this much of the hidden message:

    smart guy, you made it. the next level is

Name: Anonymous 2012-03-19 1:14

I just don't understand why it says I'm exceeding the image bounds when I'm not.
Jesus Christ you fucking retard, you are exceeding the image bounds, if you weren't then it wouldn't tell you that you were. Do you seriously believe that your software is lying to you, how fucking dumb can you get?

Name: Anonymous 2012-03-19 1:18

Haha you idiot. Why are you adding center to your x offsets in get_pixels?

Name: Anonymous 2012-03-19 1:29

>> 2
What do you suggest it is then? Sounds like you really don't know what I'm talking about.

>> 3
Because I want to take a pixel in the very center of each rectangle, just to be safe. How would that effect anything?

Name: Anonymous 2012-03-19 2:05

>>4
You wanna read the docs for get_pixel.
http://studio.imagemagick.org/RMagick/doc/image2.html#get_pixels

I don't think you understand what arguments it takes.

Name: Anonymous 2012-03-19 2:36

>>5
I read this, what am I confusing? The first two are the x and y offset, and then the dimensions of the rectangle for the second pair. I have them the same because I want to get a single pixel in the array, I tried doing a 2x2 and 3x3 array as well, however I get the same error. Thanks for the suggestion though.

Name: Anonymous 2012-03-19 2:39

dimensions of the rectangle for the second pair
I have them the same because I want to get a single pixel in the array

So you're fetching a square grid. Do I have to spell it out this much? It's NOT (from x, from y, to x, to y). It's (from x, from y, width, height).

In your case you'd want the 3rd and 4th args to be 1 and 1.

Name: >>7 2012-03-19 2:40

Sorry, not square, but a rectangular grid that is as wide as it's starting x and as tall as it's starting y.

Name: Anonymous 2012-03-19 11:56

>>7
Thanks a lot, you were right. I got it working now.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List