Jump to content

Recommended Posts

Hi guys,

I have to manage PNG images that don't come from a file, but from a TCP/IP connection. usually I use PNG data to LabVIEW image.vi to convert them into an image data cluster, but this time PNG images are different, I think. These images can be opened with all software without issues, anyway in LabVIEW PNG data to LabVIEW image.vi returns error code 1097. Unfortunately, saving received strings into temporary files is not possible in my app, so I need to convert them on the fly. have you ever seen this error?

post-18107-0-52123400-1337362179_thumb.p

attached you find a sample code and an image sample.

regards,

Claudio

image conversion.zip

Link to post
Share on other sites

My experience has been that the string based PNG VIs can not handle 32-bit images (ie. containing alpha info). The file based VIs are more robust, but still do not handle transparency very well. I have rolled my own PNG VIs, but simply writing the string to a temporary file then reading it is usually sufficient.

Link to post
Share on other sites

Thank you for your post!

So in your experience there is no way to manage a string containing an image in its native format WITHOUT storing and loading it. In my opinion, this is a bad workaround expecially if your application has to manage many pictures, but it seems to be the only one..

Link to post
Share on other sites

There can be some different structures although anything which is PNG should be readable by a PNG reader (if that makes sense).

I will take a proper look at the code myself later but I made a VI to pull the PNG files appart to see what is inside, maybe it will identify some differences? You can find the code at https://decibel.ni.com/content/docs/DOC-19620

  • Like 1
Link to post
Share on other sites

Your PNG file is actually causing an exception in what I assume are CLNs to functions in the LabVIEW library. You should submit a copy of the PNG file to NI support so they can correct their library. I'd be interested in seeing the file if it's something you can make public.

Link to post
Share on other sites

There are a variety of formats supported by PNG, my version of the PNG suite contains 157 different files. The File-based VIs will handle 154 of the 157 files. The string-based one will handle 59 of the 157. Clearly NI has written/licensed a nearly compliant PNG reader, why it is not using the same one in both cases is beyond me.

I was annoyed when I first saw the string based VIs hidden deep in the palettes (having written my own). After some quick testing the crappiness (technical term) was soon apparent so I was glad to have made the effort. The simple .NET solution may be an option for you if you are on a Windoze machine.

post-26690-0-88646600-1337627658.png

  • Like 2
Link to post
Share on other sites

There are a variety of formats supported by PNG, my version of the PNG suite contains 157 different files. The File-based VIs will handle 154 of the 157 files. The string-based one will handle 59 of the 157. Clearly NI has written/licensed a nearly compliant PNG reader, why it is not using the same one in both cases is beyond me.

Well, I'm pretty sure they use the libpng kernel for the PNG support in both cases. However as you have certainly found out the interface to libpng is not simple and the possible formats are not trivial to map to a pixel based image format like NI is using. In fact some of the features of PNG are impossible to maintain with a single 2D pixmap and an optional alpha channel. To support memory streams requires quite a bit more work too as libpng supports accessing files directly but requires extra work to support memory streams instead. So it's very easy to take a few shortcuts in one case and end up with less support for the more exotic PNG formats than when using file based input/output.

Link to post
Share on other sites

I would bet dollars to donuts that those are the functions employed by the PP'd VI and one of them is throwing the exception. Based on rolf's input, I would probably expect that there won't be much you can do about it while using only a pixmap.

Link to post
Share on other sites
  • 2 weeks later...

how do you convert an image, e.g. a jpeg one, from its binary format to a IMAQ image? I do two steps: first I pass from the binary string to an "image data" cluster and then I pass to a IMAQ image with the code below. Do you know a better way?

post-18107-0-80843200-1339532061_thumb.j

Link to post
Share on other sites

how do you convert an image, e.g. a jpeg one, from its binary format to a IMAQ image? I do two steps: first I pass from the binary string to an "image data" cluster and then I pass to a IMAQ image with the code below. Do you know a better way?

post-18107-0-80843200-1339532061_thumb.j

Your description is not entirely clear. When you say "I pass from the binary string to an "image data" cluster" you mean that you have the JPG/PNG Data to LV Image in that stream? If so there is to my knowledge a way to do the opposite for the JPG case with the IMAQ Flatten Image to String function but not in the direction you are looking for as the use of the IMAQ Flattten Image Option function and the standard LabVIEW Flatten and Unflatten functions is unfortunately also not a solution since the Flatten adds extra info to the compressed data stream, that the Unflatten seems to expect (although it seems someone in the NI forums had some success with using the resulting data stream as normal JPEG stream, until he moved to LabVIEW 64 bit and got bad results).

Link to post
Share on other sites

ah yes, I use PNG Data to LV Image and some .NET code to convert a jpeg binary string to a Image data cluster and this is my step 1. Step 2 is shown in the previous post. I think we are all agree that this solution is not nice. At the moment, is the only one I know...

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Similar Content

    • By smarlow
      Hello:  I am wondering if anyone has developed a VI to convert image data from the "Get Image" method to a PNG format string.  I do not need compression or filtering and will only store RGB (24-bit), or paletted 8-bit (optionally, but not required).  The trouble I am having is that the "write PNG file" and "LV Image to PNG" VI's are not supported in real-time.  The BMP file writer works, but is not really a web format.  I suppose I could write one, but I am under the gun on a project, and don't want to reinvent the wheel.  Thanks.
    • By smarlow
      I'm getting the "Manager Call Not Supported" when attempting to save a PNG file on an NI Phar Lap ETS target.  It's nice that the RTOS supports the "Get Image" method for control references, but being unable to save a PNG image makes that method pretty useless.  The "write BMP file" VI works just fine, but who wants to generate HTML with BMP images?  Is there a solution to the PNG vi, or has someone written an alternative?  Thanks.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.