Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reading the first row/column/channel #2

Open
yeldarby opened this issue Jan 15, 2018 · 1 comment · Fixed by yeldarby/Image#1 · May be fixed by #3
Open

Reading the first row/column/channel #2

yeldarby opened this issue Jan 15, 2018 · 1 comment · Fixed by yeldarby/Image#1 · May be fixed by #3

Comments

@yeldarby
Copy link

I may be misunderstanding but shouldn't all of these preconditions be _ >= 0 instead of _ > 0? Otherwise how do you read the first row/column/channel? image[0, 0, 0] returns an error.

https://github.com/SwiftGL/Image/blob/master/Sources/SGLImage/Image.swift#L128

public subscript(x:Int, y:Int, channel:Int) -> T {
        get {
            precondition(x > 0 && x < width)
            precondition(y > 0 && y < height)
            precondition(channel > 0 && channel < channels)
            return buffer[channel + x * channels + y * width * channels]
        }
        set {
            precondition(x > 0 && x < width)
            precondition(y > 0 && y < height)
            precondition(channel > 0 && channel < channels)
            buffer[channel + x * channels + y * width * channels] = newValue
        }
    }
@yeldarby
Copy link
Author

(Oops, accidentally submitted the pull request to my own branch rather than here which closed the issue)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant