-
-
Notifications
You must be signed in to change notification settings - Fork 378
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
ios: specify EC level/margin for generation #644
ios: specify EC level/margin for generation #644
Conversation
Not a big deal but you could add a wrapper function to provide defaults and I would not change the signature as this would break existing code. On the other hand, I am not sure how many people rely on the library and on these functions @alexmanzer. |
To simplify creation of barcodes when it is not necessary to specify EC level or margin.
Good point! I was already playing with the idea of adding a wrapper function, but wanted to keep this initial request as simple as possible. But I think you're right, and so here are two wrapper functions now. About the function signature - I know this was a bold move - but since we just introduced these functions, there's probably no existing code out there that would break, apart from our own 😉 I moved |
Haha, I actually liked the change - nothing wrong with the bold move though.
True, I can relate. Just wanted to mention that overall. LGTM, the release notes should probably contain a gentle hint if @axxel agrees to the overall change. |
In general, I'm totally fine with those changes as things stand right now. That said I'd like to refer to the age old writer API discussion (again, I know), especially this and following. I wished I had made more progress there by now but I have not. Bottom line: I'd like to introduce an
See here and here for details about the This whole size issue might convince me to separate the process into two steps (similar to what libzint is doing):
The SVG route would not have this size issue at all and I'm wondering whether that would not be the best result type to begin with? iOS should have some splendid options for rendering some SVG content in arbitrary sizes on the screen, right? Maybe start with |
For encoding/writing barcodes.
Well, while I can see why you want to get rid of width and height in favor of a simple scale parameter, as well as cleaning up ecLevel and margin, and even that it would be better to just return a clean 1x1 BitMatrix, I think all of this is probably a bit beyond this small extension of the iOS wrapper 😬 To change these things would affect all wrappers, of course, and we would like to have a way to specifiy these things now. So I would propose to tackle these changes in a second, bigger step. Of course, that would mean breaking changes, but that's what it means for all other wrappers anyway.
Something like this?
Unfortunately not 🙈 iOS doesn't support SVG directly. You can only bundle it in the assets of an app, but there are no native functions to work with SVG on iOS yet.
This is very similar to what I already do in my flavor of the Android wrapper, as you know. So I totally agree with that. But I think this would be another step for the iOS wrapper. |
My idea to bring this up now was to try to prevent (or limit) breaking changes in the iOS wrapper considering that this functionality is not really used by anyone yet (except you, it seems). If there is no SVG support in iOS, how do you currently render the result? Do you have an area where you want to render the code into and then request just that size in pixels? Is there any other vector graphic API / data format that one could use or would it be required to "manually" draw primitives directly in some form of rendering API? Thanks for the suggestion with the ZXIEncodeHints. Please merge that as you suggested. Looks like a good starting point. My two-step idea has similarities to your Android code but as far as I saw, the difference would be that the first stop would not have anything like a One thing that I'd definitively like to add/change before a release is that the width/height parameters are only going to be a hint and the returned image would then contain just the symbol with requested quiet zones (note the current implementation already interprets |
On request of @axxel.
Wouldn't that rather be an argument to merge this as it is when we are the only ones that would have to deal with the breaking change? I mean we would happily deal with it later and use it in this form in the meantime 😉
At the moment, we don't use any vector formats on iOS for barcodes. But this will change at some point, of course. I don't really know what we will use for that - that's a question @alexmanzer can maybe answer.
Merged.
Yes, that is only there because it is required for now. I would very much like to remove width/scale for the first step, too!
Sounds good! 👍 Although using negative values definitely feels like a hack 😉 But would be okay! |
Current state:
For iOS development, SVG is still a "foreign body" and you need external libs to use it. It's sad - but that's the way it is. Please correct me, if I'm wrong @benjohnde, @parallaxe and all the other iOS Devs out there. |
Thanks @alexmanzer to chime in from your vacation ;). I'll happily trust your expertise regarding SVG and iOS. But then let me repeat my earlier question: If there is no SVG support in iOS, how do you currently render the result? Do you have an area where you want to render the symbol into and then request just that size in pixels? |
Yes, at least "something like that". Example: Long Story Short: (With the scaling mode you should be careful not to use a mode that interpolates bilinearly, but only scales up-down according to e.g. nearest neighbor. But even this is not "decisive for the war" in most real world applications.) |
So from a pure iOS point of view I would say that it is either fine:
By the way, in my opinion this is the most effective way to handle e.g. a QR code as an image anyway. A b/w PNG with 64x64px (for 64x64 modules) is most likely much smaller than a SVG, where this structure is "described". For this PR, I think it would be fine to just include the pixels needed in height and width. |
Thanks for the backgound info. I just wanted to make sure the user of the API is aware that just because they specified a As for the SVG vs Bitmap discussion: once we switch to libzint, we'll have the option to ask for text rendered into the result (think EAN13). And then SVG makes a lot of sens. In-fact rendering the symbol with a module size of 1px will produce a barely readable text. |
Thanks for merging! 👍
Ah, now I understand why you're focussed on SVG! Makes sense! |
So we can specify a certain error correction level (and margin).