03-15-2013 02:46 PM
Hi All,
I am currently struggling trying to convert text that is in the picture format back to its string form. I have used "Draw Text at Point" Function (Graphics & Sounds - Picture Functions) to draw multi line text into a picture. I was able to do that just fine. Text was something like: ABC
1234
XXX
Now I would like to convert this picture format that I have created back to its original multi line String. How can I do that??
Thanks
03-15-2013 04:14 PM
@nxb wrote:
Hi All,
I am currently struggling trying to convert text that is in the picture format back to its string form. I have used "Draw Text at Point" Function (Graphics & Sounds - Picture Functions) to draw multi line text into a picture. I was able to do that just fine. Text was something like: ABC
1234
XXX
Now I would like to convert this picture format that I have created back to its original multi line String. How can I do that??
Thanks
Well once the data is drawn in a Picture control it is basically a bitmap. So reconstructing the text will require OCR functionality. Not something trivial nor cheap to do.
The best bet is likely to not even think about this roundtrip at all and find ways to access the original string directly.
03-15-2013 06:09 PM
Thanks rolfk,
I just have to try to use another approach just by using strings.
03-16-2013 02:24 PM
If the picture is new, then it would also be possible to extract the information from the commands used to build the picture, but in that case you could just do what Rolf suggested.
One thing which might help you is that if you're using a standard font, the OCR you need to do could be relatively simple and you could do it yourself. See this thread for an example, but also note that it doesn't always work as you might expect - http://lavag.org/topic/10930-how-to-i-get-the-cases-in-an-event-structure/
03-16-2013 03:10 PM
Considering your request in the other thread for shifting the text: Use two picture controls. Make the one which will have the text have a transparent background. Size both controls identically. Place the text display in front of the other control. Maintain two picture image data sets. One contains the background image while the other has only the text. When you need to shift the text, clear the (text) picture and write the text to the new location. It will take less memory and be faster and easier to keep the text in a shift register, than to try to manipulate the pixels in the image.
I have not tried this so there may be something which could prevent it from working.
Lynn
03-18-2013 09:12 PM
Hi johnsold
Based on my other thread regarding shifting multiline text in a picture, there is a way to do that. One way I have done it in my application was by using nested for loops. Specificlly I used only two for loops. The first for loop has the task to shift the selected row of the multiline text right or left whereas the second for loop has the task to position the rest of the text from other rows in their original position. Of course this nested for loop is being tied in a shift reigister so the text can be updated every time when a shift happens.
I just want to thank everybody who has tried to help me out on this issue you guys are great.
03-19-2013 02:01 AM
Why these two loops? If you have a static non-overlapping part you can create the picture stream for that once and just append the moving part each time in the loop before drawing it.
You only would need to restream static parts into the stream if you want the moving part to appear below those parts in terms of optical appearence.
03-19-2013 06:19 AM
I like the idea rolfk but I have hard time visulizing it. Is there a way to show a small example so I can see it and understand it better ?
Thanks
03-19-2013 04:03 PM - edited 03-19-2013 04:12 PM
I meant something along these lines. The reason to do it like that is that the Picture Control has actually two places where it costs quite a bit of performance. One is the building of the picture command stream itself, which is appened together with the Build String function. This function is quite slow as it has to reallocate a new memory buffer each time. The other performance bottleneck is the rendering of that stream of commands.
You can't avoid the rendering each time you want to draw a modified picture but you can avoid building the static part of your picture control stream over and over again.