OCaml Forge

Detail: [#1372] cairo_format_stride_for_width not available in the interface

Bugs: Browse | Download .csv | Monitor

[#1372] cairo_format_stride_for_width not available in the interface

Date:
2014-02-08 22:37
Priority:
3
State:
Open
Submitted by:
Erkki Seppälä (eras)
Assigned to:
Pierre Hauweele (antegallya)
Hardware:
None
Resolution:
Awaiting Response
Severity:
normal
Version:
None
Component:
Cairo
Operating System:
Linux
Product:
Cairo
 
URL:
Summary:
cairo_format_stride_for_width not available in the interface

Detailed description
The function is required for using Cairo.Image.create_for_data8 properly (ie. create data with correct stride). Otherwise the stride may end up being invalid. No idea what is a correct stride and what is incorrect..

The function is already available with name Cairo.Image.c_stride_for_width but it's not exported in the interface. I recommend renaming it to stride_for_width in the process.

Here is an example how the Cairo documentation expects the function to be used: http://cairographics.org/manual/cairo-Image-Surfaces.html#cairo-format-stride-for-width

Followup

Message
Date: 2015-07-06 12:47
Sender: Christophe Troestler

The discussion is to be continued on https://github.com/Chris00/ocaml-cairo/issues/2
Date: 2014-02-08 23:52
Sender: Pierre Hauweele

To add on your "No idea what is a correct stride and what is incorrect.." and on my "it has no real use for the user", the stride is the actual number of bytes in a pixel row from the data, counting unused alignment bytes. A correct stride is basically a value such that the pixel row is padded with some bytes to align to 4bytes words. The idea of stride_for_width is to give the opportunity to the user to allocate a good number of bytes for data. But Image.create_for_data8 is actually there in OCaml for when the user didn't allocate that data himself. Otherwise, he would have used Image.create (and then Image.get_data8 if he needs the underlying bigarray). In the case he is forced to use create_for_data8, the user actually don't have any control on the stride anymore, and if it wasn't allocated with a valid stride in the first place, then the situation cannot be rectified. That is why I think [stride_for_width] has virtually no need to be exported. Therefore I think I will change the resolution as won't fix, but will update the documentation if your use case don't justify the use of that primitive.
Date: 2014-02-08 23:02
Sender: Pierre Hauweele

Actually, create_for_data8 already gives Cairo a stride computed by stride_for_width if the [stride] optional argument is not defined. Not specifying the optional stride thus makes the code behave as expected in the Cairo documentation. Specifying a custom stride is then considered as "you know what you are doing" as in the original Cairo function.

I will update the documentation to make it clear and will also export the stride_for_width function despite the fact that it has no real use for the user.

Attached Files:

Changes:

Field Old Value Date By
ResolutionAccepted As Bug2014-02-08 23:52antegallya
ResolutionNone2014-02-08 23:02antegallya
assigned_tonone2014-02-08 23:02antegallya