-
-
Notifications
You must be signed in to change notification settings - Fork 397
Update GetQRCode.ashx.cs to allow RGBA values #5989
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
Conversation
nairdo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Noah. Can you check out these small adjustments? Let me know if you have any questions/concerns.
RockWeb/App_Code/GetQRCode.ashx.cs
Outdated
| } | ||
| } | ||
| catch ( Exception ) | ||
| catch (Exception) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please retain the whitespace here and in the if below.
| } | ||
| } | ||
|
|
||
| private byte[] HexToByteArray( string hex ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even though these two new methods are private, it's a good idea to add method /// documentation to describe what the intention of each method is -- but especially this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: We'll be minimally adding a small section next to this section in the Developer 101 guide around here:
https://community.rockrms.com/developer/book/16/16/content#referencingfilesandimages
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nlBayside Also check the foreground and background colors when used with SVG vs PNG... I think you might have one of them reversed.
var lightColor = HexToByteArray( foregroundColor );
var darkColor = HexToByteArray( backgroundColor );The lightColor should be the background color while the darkColor is the foreground (for the PNG output type).
|
Let me know if those changes suffice! I had it done in the browser editor. So if I missed something I can go back and fix that |

Proposed Changes
https://community.rockrms.com/ideas/2009/allow-customizable-colors-for-qr-codes
This change allows for RGBA hex values in the QR Code generator. These values can come in as RRGGBB, or RRGGBBAA hex values.
Types of changes
What types of changes does your code introduce to Rock?
Put an
xin the boxes that applyChecklist
Put an
xin the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.Further comments
I made these changes with 6 and 8 digit RGBA values in mind, not 3 or 4-length values (like CSS allows). If that is something people would also like to see in the change, I can accommodate that. I think it would be useful to incorporate the RockColor utilities class into this because it has a Dictionary of CSS hex values and their keywords.
The only downside of that is that you still need to convert the hex values into a
byte[]because of QRCoder's method overloads.Documentation
New documentation should be applied once these changes are made so that users understand the flexibility they now have when creating QR codes.