1. Malek Taha
  2. PowerBuilder
  3. Monday, 11 March 2024 22:11 PM UTC

Hi 

    I imported Bruce Armstrong  qrcodegenerator dll into my pb 2023R3 application and it worked fine.

 

I created a function that takes a string text and return a Blob using the same code that Mr. Armstrong used in the demo.

It worked fine if i have a picture control in a window.

When i have a picture control in a datawindow it does not work.

Can someone please help me on how i can do this.

 

This is crucial to our application as it generates labels and we use datawindows to make these labels

Thank You

Malek Taha

 

ls_base64 = inv_generator.of_generateqrcode( "This_is_a_testQR" )

co = create CoderObject

lblb_qrcode = co.base64decode(ls_base64)

destroy co

p_1.setpicture( lblb_qrcode ) // this worked

dw_1.object.p_1.setpicture( lblb_qrcode) // This does not work

 

 

Bruce Armstrong Accepted Answer Pending Moderation
  1. Thursday, 14 March 2024 17:30 PM UTC
  2. PowerBuilder
  3. # 1

The issue is that what I'm returning from the C# wrapper for QrCoder is a byte array (64 bit encoded so I can pass it back to PowerBuilder as a string), not a bitmap.  What you might want to do is modify the wrapper assembly code so that you can pass in a filename to save the data to.  

Then change this:
byte[] qrCodeBytes = pngByteQRCode.GetGraphic(20);
string qrCodeString = Convert.ToBase64String(qrCodeBytes);
return qrCodeString;

To something like

Bitmap bitmap=pngByteQRCode.GetGraphic(20);
bitmap.Save( <filename you passed in>, System.Drawing.Imaging.ImageFormat.Jpeg)

Comment
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Thursday, 14 March 2024 02:59 AM UTC
  2. PowerBuilder
  3. # 2

The contents of malek_test.bmp do not appear to be correctly formed, although Paint can open it, the Picture DWObject in PB cannot.

Using Paint, I opened malek_test.bmp, then immediately did a "Save As" to a JPG file named "malek_new_test.jpg". After changing the script to assign the JPG to the Picture DWobject in dw_1, the jpg file displays. Returning to Paint, I did another "Save As" to a BMP named "malek_new_test.bmp". After changing the script again to now assign the NEW BMP, it displays also:

I don't know how you created the BMP named "malek_test.bmp", but that process appears to be faulty in some manner and results in PB not being able to display it in a Picture DWObject. I'm not going to be any help to you in determining what is causing this incorrect BMP.

By the way, the BMP graphics format is a very bloated format. JPG's are much more compact.

Best regards, John

Comment
There are no comments made yet.
Malek Taha Accepted Answer Pending Moderation
  1. Wednesday, 13 March 2024 19:49 PM UTC
  2. PowerBuilder
  3. # 3

Hi John

       Attached is a sample application in 2022R3 that Bruce armstrong wrote and i added a couple of objects for testing

 

on clicking encode, 

1 it generates a QR code blob which i saved to a file (malek_test.bmp)and do a Setfile of the blob to p_1 on the left top and P_2 on the left bottom both sets and read as expected

2)  I set the right top datawindow with a picture control with the saved file generated from the blob (malek_test.bmp) and this does not work

3)  I set the right bottom datawindow with a picture control with a stock bitmap of a qrcode (malek.bmp) and this does work

 

The code is in the encode button

Not sure what i am missing

Please advise

Thanks

malek

 

 

 

Attachments (1)
Comment
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Tuesday, 12 March 2024 00:53 AM UTC
  2. PowerBuilder
  3. # 4

Hi, Malek - 

As you have noted, there is no SetPicture method for a DataWindow's Picture DWObject. As far as I know, the only way you can display a picture stored in a Blob variable in a Picture DWObject is by first writing the blob to a file, then setting the Picture DWObject's Filename property to the newly-created file's path and name. Admittedly, this is not ideal for what you are needing to accomplish.

Best regards, John

Comment
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.