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

The specification for the cmsDoTransformLineStride/BytesPerPlane{In,Out} could be improved #314

Closed
mrserb opened this issue Apr 9, 2022 · 3 comments

Comments

@mrserb
Copy link
Contributor

mrserb commented Apr 9, 2022

The specification for the BytesPerPlaneIn/Out parameters of the cmsDoTransformLineStride is not clear for some cases and probably can be improved. As I understand cmsDoTransformXXX API:

  1. "Case 1": If the image does not have any gaps between the pixels and lines -> pixel's stride is equal to the pixel's size and line's stride is equal to the "pixel's size" * "the number of pixels" -> the simple call to the cmsDoTransform() can be used.
  2. "Case 2": If the lines in the image have some extra padding bytes then as suggested in the tutorial the cmsDoTransform() can be called in the loop per scanline or the cmsDoTransformLineStride can be used as suggested by the "Fast floating point plugin" doc.
  3. "Case 3": If the pixels in the image have some extra padding bytes then cmsDoTransform() can be called in the loop per pixel, or the cmsDoTransformLineStride can be used.

For all cases above I tried to use the cmsDoTransformLineStride function, all its parameters are obvious except the BytesPerPlaneIn/Out. According to the documentation "BytesPerPlaneIn{In,Out}: The distance in bytes from one plane to the next one inside a line. Only applies in planar formats.":

Here are a few questions I think the documentation can clarify:

  1. Can these parameters be ignored if "planar formats" are not used? if not then:
  2. In the "Case 1" above, inside the cmsDoTransform these values are calculated as the "number of pixels" * "pixel's size" which is just all pixels in the image w/o gaps. But is it possible to calculate this value using the "public" CMSAPI? The PixelSize function used in the cmsDoTransform is not public.
  3. What these values should contain for the "Case 2" above, when the line has only one "plane": should it be zero, should it be the "number of pixels in the line" * "pixel's size", or it should be equal to the BytesPerLine{In,Out}?
  4. What these values should contain for the "Case 3" above, for example, if the pixels of TYPE_ARGB_8 format have 1-byte gap in between, should the 5 be used, which is "size of the pixel" + "size of the gap"?

Thank you for any clarification, probably I misread some docs.

@mrserb mrserb changed the title The specification for the cmsDoTransformLineStride/BytesPerPlaneIn/Out could be improved The specification for the cmsDoTransformLineStride/BytesPerPlane{In,Out} could be improved Apr 9, 2022
@mm2
Copy link
Owner

mm2 commented Aug 27, 2022

Fixed in 4a3ceda

@mm2 mm2 closed this as completed Aug 27, 2022
@mrserb
Copy link
Contributor Author

mrserb commented Oct 9, 2022

Thank you! The new documentation looks great!

@mrserb
Copy link
Contributor Author

mrserb commented Dec 3, 2022

One more question about the "return" of this function. According to the tutorial in Little CMS2, there are no longer error handlers. When a function fails, it just returns the failure status. And there are many functions that actually return their status, but cmsDoTransformLineStride returns nothing, does it mean that it always passes? (assuming that the pointers/offsets are correct - and the app will just crash if pointers/offsets are incorrect)

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

No branches or pull requests

2 participants