1. Miguel Leeuwe
  2. PowerBuilder
  3. Thursday, 28 October 2021 07:47 AM UTC

Hi,

I've created a C# DLL which encodes and decodes QR images. You can save as .bmp, .gif, .png, and .jpg. The problem I'm having is that only files with a .PNG extension show correctly on the picture control. If for example I have saved as BMP, I can correctly open and see the image with any windows image application, but not in powerbuilder on the picture control.

Has anyone seen this before? I guess there's something wrong with the generated bmp or with powerbuilder not recognizing it as such.

(In .net, I'm using the zxing nuget package to encode and decode. This is a 4.5.1 32 bit .net framework dll, since we still have customers using windows server 2003m win7 and possibly even win XP).

See the 2 attachments: one is my VS DLL library with the encoding and decoding functions and the other is a small pb sample application made in pb2019 R3 build 2703.

Edited: to avoid dupliction:

Here's the latest version of the PB sample app: https://github.com/mjl38/PB_sample_app_QRCodes
And here's the latest version of my Vstudio .net library (and test window form): https://github.com/mjl38/QRCodes
Let me know if you would like me to zip it all and duplicate it on the several posts here.

TIA, MiguelL

 

Miguel Leeuwe Accepted Answer Pending Moderation
  1. Thursday, 28 October 2021 21:55 PM UTC
  2. PowerBuilder
  3. # 1

For now my improved 3rd version. It should deal better with the different image formats, but still some seem to fail (like .tiff).

See attached.

regards.

 

Edited: to avoid duplication:

Here's the latest version of the PB sample app: https://github.com/mjl38/PB_sample_app_QRCodes
And here's the latest version of my Vstudio .net library (and test window form): https://github.com/mjl38/QRCodes
Let me know if you would like me to zip it all and duplicate it on the several posts here.

 

Comment
There are no comments made yet.
Mark Goldsmith Accepted Answer Pending Moderation
  1. Thursday, 28 October 2021 20:10 PM UTC
  2. PowerBuilder
  3. # 2

Hi Miguel,

The Save method is overloaded and so there are other ways to call it. One way is to also pass the image format in which you would like to save it. So, instead of result.Save(imageFilename) you would have something like result.Save(imageFilename, System.Drawing.Imaging.ImageFormat.Bmp or .Png, .Jpeg etc.).

I think the guy in the video whose links you shared, which were interesting by the way so thanks, assumed that if you changed the extension it would automatically change the image format but without the second parameter it defaults to PNG format.

HTH...regards,

Mark

Comment
  1. Miguel Leeuwe
  2. Thursday, 28 October 2021 20:35 PM UTC
I think the VS solution should now be accessible on Github: https://github.com/mjl38/QRCodes

(I'm also a noob on Github, so forgive me if it doesn't work).

regards.
  1. Helpful
  1. Miguel Leeuwe
  2. Thursday, 28 October 2021 20:45 PM UTC
I have this big "switch case" statement. I would say there should be a better way to do what I'm doing, but ... it seems to work.
  1. Helpful
  1. Miguel Leeuwe
  2. Thursday, 28 October 2021 20:53 PM UTC
Here's where I found the information on the image formats: https://parallelcodes.com/creating-qrcode-image-in-c/

  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Thursday, 28 October 2021 13:14 PM UTC
  2. PowerBuilder
  3. # 3

I've uploaded a newer version of both the powerbuilder app and the VS DLL and source code. Files were being kept in a lock, which should have been solved now. Also, I had to apply some encoding to allow for languages like Arabic and Chinese to work correctly.
See the attached files.
regards.

Edited: to avoid duplication:

Here's the latest version of the PB sample app: https://github.com/mjl38/PB_sample_app_QRCodes
And here's the latest version of my Vstudio .net library (and test window form): https://github.com/mjl38/QRCodes
Let me know if you would like me to zip it all and duplicate it on the several posts here.

 

Comment
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Thursday, 28 October 2021 11:15 AM UTC
  2. PowerBuilder
  3. # 4

Hmm,

I've tested with same text and saving as all different image types. The files are identical! This means that ZXing must be saving them all as PNG files.

I've tried to figure out how to save as different formats, but can't find anything yet.

So yes, my conclusion is that the BMP doesn't show, because in reality it's a PNG.

If I ever figure it out, I'll post the solution here.

For now, I mark this as resolved.

regards.

Comment
  1. Miguel Leeuwe
  2. Friday, 29 October 2021 16:49 PM UTC
I think I've managed to save correclty in different file formats :)
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.