Skip to main content
7-Bedrock
December 29, 2018
Solved

.NET SDK

  • December 29, 2018
  • 1 reply
  • 1630 views

I have a .NET SDK edge application written in C#.  I am using the GetNamedPropertyValuesVTQ call to return a set of properties from a THING.  One of the properties is an image.  Casting to IMAGEPRIMATIVE or byte[] shows a length of 0 in debug mode.  Double question set is:

1. How can you convert an ImagePrimative to a C# image to be able to persist the image to client folder. 

2. Is there an alternative way to download the image property into an edge application (C#)?

Best answer by pgrodowski

Hello,

 

The cast seems to fail (return 0) because the image returned from the InfoTable is encoded in base64.

First decoding and then casting on the result may work (untested). directly casting does not work because there might not be a constructor / operator for the target type you're casting to that accepts base64 encoded data . You should then be able to save the type (for example if you choose a byte array) to a file, which will represent the ImagePrimitive.

 

Please let me know if you have any questions.

 

Regards,

Pascal

1 reply

5-Regular Member
January 15, 2019

Hello,

 

The cast seems to fail (return 0) because the image returned from the InfoTable is encoded in base64.

First decoding and then casting on the result may work (untested). directly casting does not work because there might not be a constructor / operator for the target type you're casting to that accepts base64 encoded data . You should then be able to save the type (for example if you choose a byte array) to a file, which will represent the ImagePrimitive.

 

Please let me know if you have any questions.

 

Regards,

Pascal

Support
January 25, 2019

Hi @droach.

 

If the response provided by @pgrodowski answered your question, please mark it as the Accepted Solution for the benefit of others with the same question.

 

Regards.

 

--Sharon