Page 1 of 4

hpwMimeEncodeFile question

PostPosted: Wed Dec 21, 2011 9:06 pm
by David de Argentina
Hi all,

I use hpwMimeEncodeFile function to convert an image file to a encoded one, and send it via UDP across internet.

The function i use has a predefined format:

Function "Receiver_IP|Receiver_Port|message"

Note the PIPE character is used as separator

Message component has several subcomponents:


Note the middle dot is used as separator. (the dot over the "3" key)

As I don't have idea if this character (the middle dot) could be used into the encoded file, I need know what is the range of characters (usually between 32 and 127) that can be used by the hpwMimeEncodeFile function, in order to avoid a parse error.

Does any know about this ?

Thanks in advance,
David de Argentina

PostPosted: Thu Dec 22, 2011 10:56 am
by HPW
Hello David,

Since it use the Mime Base64 standard format you can look here:

The base64 index table does not contain neither the pipe nor any dot.

Not sure if this answers your question.

PostPosted: Thu Dec 22, 2011 8:03 pm
by David de Argentina
Thanks Hans-Peter,

I had replaced the middle dot with [#13] and works fine.

Greetings from Buenos Aires,
David de Argentina

Re: hpwRtfToBitmap question

PostPosted: Mon Oct 14, 2013 11:55 pm
by schmutly
Hello can i ask,
Im using a plugin and can send to a remote TCPIP publication across internet no probs.
Am i able to use, Hans, the hpwBitmapToRtf and send that as text and on the receiver
use hpwRtfToBitmap then ImageWindow to Show the image the other end?
It seems that should work but i may be missing something.
Basically want to send a screenshot & convert it to RTF this end and recombine it
at remote...that's ONE use of using hpwRtfToBitmap ?... or do i need to use something else?

Thanks for your help,

Re: hpwMimeEncodeFile question

PostPosted: Tue Oct 15, 2013 3:52 am
by HPW

hpwImageToRTF can make the RTF text.
hpwRtfToBitmap from hpwUitlity could make the file.
So it may work.

Maybe hpwImageSaveToMimeStream/hpwImageLoadFromMimeStream can be an option.
hpwMimeEncodeFile with a native bitmap file and hpwMimeDecodeFile to get it back can also be an option.


Re: hpwMimeEncodeFile question

PostPosted: Tue Oct 15, 2013 4:33 am
by schmutly
Thanks Hans,
I'll try that now

Re: hpwMimeEncodeFile question

PostPosted: Tue Oct 15, 2013 5:08 am
by dec

Maybe you also like to considerer the Base 64 related actions from my npUtils plugin.

Re: hpwMimeEncodeFile question

PostPosted: Tue Oct 15, 2013 5:20 am
by schmutly
Hi David,
I'm actually using your npTalk with a friend in Aust.
IM using your npScreenAreaShot trying to convert it or encode it to
text and send to the other Pub and reencode it there.
the button has:
npScreenAreaShot "255,0,0" "0,255,0" "[TempDir]a.bmp" "[Result]"
hpwMimeEncodeFile "[TempDir]a.bmp" "a.bmp"
GoSub "SendImage"
with Gosub as:
npTalkClientSendText "[ClientID]" "a.bmp" "[Result]"

The receiving Pub has:
If "[Socket.ReceivedText]" "=" "calling"
If "[Socket.ReceivedText]" "<>" ""
hpwMimeDecodeFile "a.bmp" "[TempDir]a.bmp"
ImageWindow "" "-1" "-1" "[TempDir]a.bmp"
SetVar "[ServerLog]" "[ServerLog]Robbie said: [Socket.ReceivedText][#13]"
SetVar "[WindowState]" "normal"

If i can just get this to work 'be great, im SURE it can be done.
Is there something wrong above, i miss a step?

Just had a bit of a i have to convert it to Base64 THEN send it as text, re-encode back to Base64 at other end, correct?
A line or two of code, for an example would be appreciated, thanks..the Base64, new to me :/

Re: hpwMimeEncodeFile question

PostPosted: Tue Oct 15, 2013 5:31 am
by dec

The npTalk plugin can deal with text, so in principle is possible to send an encoded image (in a Base64 string, for example), but I am not sure if we can get here with some limitations in the text to be send, in terms of the text lenght. In other words, a base64 codified image can be a very large text, which I am not sure if we can send. You need to make your tests about this.

If we found some text limitation probably can take some alternatives, for example:

1º Reduce the image size (width and height) in order to get a more less text ammount

2º Put the image in some FTP server, for example, and send the appropiate path to the other publication

Try using the "npBase64EncodeFile" action from my npUtil plugin to encoded the captured image. You can do this only one time in order to test if the appropiate text arrive to your other publication. And in this other publication you can try with the "npBase64DecodeFile" action in order to save the base 64 text to an image file.

P.S.If I am not wrong you can use also the Hans Peter plugins actions instead of the refered base 64 actions from my npUtil plugin: I mentioned it in a try to be more clear in my explanation.

Re: hpwMimeEncodeFile question

PostPosted: Tue Oct 15, 2013 5:35 am
by schmutly
Thanks David, ill try ALL of them lol.
Also, im using the rubber-band of your npScreenAreaShot to grab only SMALL
sections of screens when im trying to explain something to them, so it wouldnt
even be a large screen area....
But will try theory it should work...
Trying now, and thanks you guys,

Re: hpwMimeEncodeFile question

PostPosted: Wed Oct 16, 2013 12:20 am
by schmutly
Pretty frustrated, been on this all day :/
I tried many of the example actions that were
recommended,and locally on my PC some of those
DO send the image to the other PUB.
For some reason it seems like the receiver Pub doesn't
re-encode the text back into image, i must be missing a STEP
because it seems to work on my PC. The screens are below,
one of the receiver button & Subroutine and the sender with
its subroutine , when it receives the data stream.
Watching the Variables, sometimes the variable seemed BLANK but
if i put my mouse in there, there IS data on that line.
Can anyone point me in right direction?
The hpwMimeEncodeFile action seemed to work locally, i probably
am missing a step, or i cant use [PubDir]..not sure.

Re: hpwMimeEncodeFile question

PostPosted: Wed Oct 16, 2013 1:54 am
by dec
Hello Rob,

Please, think on this questions:

1º Are you sure you can write into the "[PubDir]" directory? Remember you can't do it if your publication is placed into "C:\Program Files", for example, and depending of the Windows version. I am thinking more on the destination publication.

2º Before call the "ImageWindow" action, prove that "[PubDir]a.bmp" really exists using the "FileExists" action.

3º You are using "npBase64DecodeStr" action, but, you need to use "npBase64DecodeFile" instead. Only this can cause the problem, since the first action do not save anything into the target file, but offer you the decoded text in a variable. Instead "npBase64DecodeFile" decode the base 64 to a file, and also offer you a result variable.

4º Use the result variable of the actions to prove these are correctly execute. When you get a "False" into the result variable (or maybe other possible values, you need to read the action's manual), take a look at the "[LastError]" variable which contain information about the possible error.

Please, test the step 3 carefully, the pair action for "npBase64EncodeFile" is "npBase64DecodeFile", and not "npBase64DecodeStr".

Re: hpwMimeEncodeFile question

PostPosted: Wed Oct 16, 2013 2:04 am
by schmutly
Ok, thanks David..will check the results.
If you notice, ABOVE the npBase64DecodeStr
was a .npBase64DecodeFile <--i tried this too..i think it was succesful, LOCALLY.
But i didn't consider the if "file exists"..will investigate that.
Ill go through this steps slowly,
thanks for your time..will update more when i relax, rethink it through.


Re: hpwMimeEncodeFile question

PostPosted: Wed Oct 16, 2013 4:38 am
by schmutly
i put checks in each pub.I created a folder in c: and it seems
that it doesn't create an image on the receiver PC folder.
The images below look fine to me except maybe the decode into a a.bmp
is not being made because i need to do something first before that step?
I cannot find the last-error in the list...will try again tomorrow.


I think the problem only is getting BACk from the Base64 to an image as the variable
seems to hold the correct data. I took this data from variable and pasted it to this online
Base64 Decoder with output as a.bmp and it correctly decoded the tree image.
So don't know what im doing wrong..
Pasted The Variable code
into Online Encoder.

Re: hpwMimeEncodeFile question

PostPosted: Wed Oct 16, 2013 5:43 am
by dec

Well. I have some bad news. I want to enhance the npTalk plugin samples in order to send an image codificated in base 64, just to shows you how can be doing. You can take a look at the Server and Client enhanced samples downloading from this link:

However... The send image operation do not work like we can expected all the time. Why? I cannot understand very well at this momment and I am investigating for a possible workaround, but the problem is that some times the received text is "chunked", and this is not something that the plugin does, but the "low level socket" does.

So in the above example you can found that sometimes the image are well transmited and show, because all the text (base 64) are recieved in one step. But when the text is chuncked by the socket (behind the plugin) the recieved text is not complete and then we cannot decode the appropiate image. I am now searching for a way in that the plugin can assert all the received text are available, but to be honest this is something new to me and don't know exactly how to achieve.

As I say I am now working for a possible solution. Sorry for the inconveniences. :oops: