Replies: 9 comments 19 replies
-
always love me some c api's :) it is very useful indeed |
Beta Was this translation helpful? Give feedback.
-
Hey @axxel! The C API seems to behave well so far. I noticed a slight RSS memory increase (40~60MiB out of ~270MiB) with high resolution images (2592x1944). Unsure of the cause yet. Lower resolutions have lower memory increase too, that's why this is not worrying for me. I had trouble compiling because of the And for my use case I added The only thing I'm still doing myself is getting the result out, to avoid one unnecessary allocation. This is probably not a problem if using C directly; it's only a problem for me because getting the result into Go's GC implies another copy. |
Beta Was this translation helpful? Give feedback.
-
I added a |
Beta Was this translation helpful? Give feedback.
-
While working on the Rust wrapper and now looking into a .NET wrapper, I realized that having zxing_ReaderOptions opts { .tryHarder = true, .formats = zxing_BarcodeFormat_QRCode};
opts.minLineCount = 1;
zxing_ImageView iv { .data = NULL, .width = 100, .height = 20, .format = zxing_ImageFormat_RGB };
zxing_Results* results = zxing_ReadBarcodes(iv, opts);
zxing_Results_delete(results); This would then even allow something as concise as the following: results = zxing_ReadBarcodes((zxing_ImageView){NULL, zxing_ImageFormat_Lum, 100, 20}, zxing_ReaderOptions_default()); One thing that is still worrying me is the fact that bitfield structs like Note that I recently already added a simple @siiky / @hoisagen do you see any issue with that approach (apart from being an API incompatible change...). |
Beta Was this translation helpful? Give feedback.
-
Re `struct zint_symbol` transparent, yes, it does cause issues, e.g.
this recent ticket https://sourceforge.net/p/zint/tickets/303/.
Re dealing with ABI breaking changes, I don't! - just increment the version.
…On Thu, Jan 25, 2024 at 2:57 PM axxel ***@***.***> wrote:
You are right about the increased ABI stability and yes, I certainly know enough about this stuff to be concerned. I don't see too much of a benefit in this case because the c-ABI version is tied to the c++ ABI version (SONAME) because they are part of the same binary. So if I change something on the c++ side and increase the SONAME that means the c-clients will need to be re-compiled anyway even if the c-ABI did not change at all. This is in and of itself not really a beneficial feature but I don't know how to prevent that other than distributing the c-API in a separate library, which I'd rather not because of the increased complexity.
If ImageView and ReaderOptions where anything like a mutable, stateful object (e.g. like the struct sqlite3) I would definitively stick to the opaque pointer. But they are actually just two collections of function parameters that are mainly there to allow to define a set of default values that don't have to be provided by the caller. In the Python API, the ReaderOptions struct does not exist because the language itself allows to selectively set optional parameters (like read_barcodes(image, format=QRCode, tryHarder=true)).
If the API would look like void read_barcodes(char* data, int size, format_t format, bool return errors); I would definitively not think about introducing a heap-allocated struct to pass the enum and the bool to the function via a pointer. And conceptually this is the same situation.
And don't worry, the manual bitfield manipulation via enum flags is not going to happen. That would be kind of the worst of both worlds.
@gitlost have you ever regretted that struct zint_symbol is a transparent struct? How do you deal with ABI breaking changes?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
I just released an alpha version of the .NET wrapper an it turns out, I had bug in the handling of the return value of |
Beta Was this translation helpful? Give feedback.
-
Another addition to the c-API is this zxing_ImageView* zxing_ImageView_new_checked(
const uint8_t* data, int size, int width, int height, zxing_ImageFormat format, int rowStride, int pixStride); which includes a new I was contemplating whether this new function should be called |
Beta Was this translation helpful? Give feedback.
-
Following, since I am trying to evaluate if I can use this at work, preferably in C, but cpp may also work. |
Beta Was this translation helpful? Give feedback.
-
While summing up the history and the current state of the naming situation in #720, I realized that the prefix |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Thanks to @siiky we now have a new C-API, see #553. This currently only covers the reading part and is implemented as a "wrapper". If this turns out to be useful, I intend to merge that with the core library, such that is comes with every zxing-cpp installation out of the box. Before I do that I'd like to get some feedback from the community, though.
If you have a use for this, please drop me a line. If you have suggestions on how to improve the API, let me know as well!
EDIT: added a README with more info.
Beta Was this translation helpful? Give feedback.
All reactions