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

Handle layer's negative top or left #46

Closed namse closed 8 months ago

namse commented 1 year ago

closes https://github.com/chinedufn/psd/issues/45

Other little code changes by rust-analyzer and rustfmt automatically.

namse commented 1 year ago

Hmm. the problem is very complex here.

rgba_idx could be negative if the layer's top and left is negative. It's not considered in code.

namse commented 1 year ago

@chinedufn I think you have to make a decision about the design of rgba_idx.

Here are my suggestion,

  1. rgba_idx returns signed integer and user check it's negative
  2. rgba_idx returns Option<usize> to prevent negative index
namse commented 1 year ago

I put the change that fn rgba_idx(...) returns Option<usize> at commit e4a008b.

chinedufn commented 1 year ago

Thanks for working on this! Will review this over the weekend.

I haven't looked at the code yet, but if you haven't already please add test(s) for the things that you fixed.

These tests should have failed before your fixes and pass after your fixes.

namse commented 1 year ago

I see, I have a psd file that makes error with previous code. Give me some time to put test. :)

kevzettler commented 8 months ago

@namse I created a PR to add tests to your branch https://github.com/namse/psd/pull/1

@chinedufn this PR seems to fix few issues #45 #26 #43 and would be good to get in for a release

kevzettler commented 8 months ago

@namse @chinedufn I have created a new PR at #52 which contains all the changes from this PR with the test cases. We can close this in favor of #52

chinedufn commented 8 months ago

Added a commit with both of you as co authors https://github.com/chinedufn/psd/commit/a57f32fc5d300e3a5398aa313b74cb4461907f69