Skip to content

Reading the first row/column/channel #2

@yeldarby

Description

@yeldarby

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
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions