chinedufn / psd

A Rust API for parsing and working with PSD files.
https://chinedufn.github.io/psd
Apache License 2.0
265 stars 40 forks source link

psd.group_by_id() expects vector index whereas group IDs range 1..n #27

Closed gregl83 closed 2 years ago

gregl83 commented 2 years ago

Iterate Groups

for group in psd.groups().iter() {
    let group_id = group.id() as usize;
    // first group has value of 1

    let group = psd.group_by_id(group_id);
    // second group returned since vector index of 1 is second element
}

Get Group by ID

/// Get a group by id.
pub fn group_by_id(&self, id: usize) -> Option<&PsdGroup> {
    self.layer_and_mask_information_section
        .groups
        .item_by_idx(id)
}
chinedufn commented 2 years ago

Thanks for opening this!

28 fixes this.