Source language: Translate to:

hpwMimeEncodeFile question

Questions about NeoBook PlugIns

Moderator: Neosoft Support

hpwMimeEncodeFile question

Postby David de Argentina » Wed Dec 21, 2011 9:06 pm

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:

"Code·Sender_IP·Sender_Port·Text·Encoded_Data"

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
User avatar
David de Argentina
 
Posts: 1553
Joined: Mon Apr 04, 2005 4:13 pm
Location: Buenos Aires, Argentina

Postby HPW » Thu Dec 22, 2011 10:56 am

Hello David,

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

http://en.wikipedia.org/wiki/Base64#MIME

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

Not sure if this answers your question.
Hans-Peter
User avatar
HPW
 
Posts: 2510
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany

Postby David de Argentina » Thu Dec 22, 2011 8:03 pm

Thanks Hans-Peter,

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

Greetings from Buenos Aires,
David de Argentina
User avatar
David de Argentina
 
Posts: 1553
Joined: Mon Apr 04, 2005 4:13 pm
Location: Buenos Aires, Argentina

Re: hpwRtfToBitmap question

Postby schmutly » Mon Oct 14, 2013 11:55 pm

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,
Rob.
schmutly
 
Posts: 217
Joined: Fri Feb 20, 2009 4:16 pm

Re: hpwMimeEncodeFile question

Postby HPW » Tue Oct 15, 2013 3:52 am

Hello,

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.

Regards
Hans-Peter
User avatar
HPW
 
Posts: 2510
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany

Re: hpwMimeEncodeFile question

Postby schmutly » Tue Oct 15, 2013 4:33 am

Thanks Hans,
I'll try that now
Cheers,
Rob
schmutly
 
Posts: 217
Joined: Fri Feb 20, 2009 4:16 pm

Re: hpwMimeEncodeFile question

Postby dec » Tue Oct 15, 2013 5:08 am

Hello,

Maybe you also like to considerer the Base 64 related actions from my npUtils plugin.
.
Enhance your NeoBook applications!
.
57 plugins, 1113 actions and 230 samples
.
NeoPlugins website: www.neoplugins.com
.
User avatar
dec
 
Posts: 1663
Joined: Wed Nov 16, 2005 12:48 am
Location: Spain

Re: hpwMimeEncodeFile question

Postby schmutly » Tue Oct 15, 2013 5:20 am

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:
:SendImage
npTalkClientSendText "[ClientID]" "a.bmp" "[Result]"
Return

The receiving Pub has:
:OnServerRead
If "[Socket.ReceivedText]" "=" "calling"
AlertBox "ARE YOU THERE?" "CALLING CALLING!! Need TO TALK ASAP!!!"
else
If "[Socket.ReceivedText]" "<>" ""
hpwMimeDecodeFile "a.bmp" "[TempDir]a.bmp"
ImageWindow "" "-1" "-1" "[TempDir]a.bmp"
else
SetVar "[ServerLog]" "[ServerLog]Robbie said: [Socket.ReceivedText][#13]"
SetVar "[WindowState]" "normal"
Return

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?
Rob

EDIT:
Just had a bit of a read..so 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 :/
schmutly
 
Posts: 217
Joined: Fri Feb 20, 2009 4:16 pm

Re: hpwMimeEncodeFile question

Postby dec » Tue Oct 15, 2013 5:31 am

Hello,

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.
.
Enhance your NeoBook applications!
.
57 plugins, 1113 actions and 230 samples
.
NeoPlugins website: www.neoplugins.com
.
User avatar
dec
 
Posts: 1663
Joined: Wed Nov 16, 2005 12:48 am
Location: Spain

Re: hpwMimeEncodeFile question

Postby schmutly » Tue Oct 15, 2013 5:35 am

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 this..in theory it should work...
Trying now, and thanks you guys,
Rob
schmutly
 
Posts: 217
Joined: Fri Feb 20, 2009 4:16 pm

Re: hpwMimeEncodeFile question

Postby schmutly » Wed Oct 16, 2013 12:20 am

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.
Image
Image
Image
schmutly
 
Posts: 217
Joined: Fri Feb 20, 2009 4:16 pm

Re: hpwMimeEncodeFile question

Postby dec » Wed Oct 16, 2013 1:54 am

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".
.
Enhance your NeoBook applications!
.
57 plugins, 1113 actions and 230 samples
.
NeoPlugins website: www.neoplugins.com
.
User avatar
dec
 
Posts: 1663
Joined: Wed Nov 16, 2005 12:48 am
Location: Spain

Re: hpwMimeEncodeFile question

Postby schmutly » Wed Oct 16, 2013 2:04 am

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.

Rob
schmutly
 
Posts: 217
Joined: Fri Feb 20, 2009 4:16 pm

Re: hpwMimeEncodeFile question

Postby schmutly » Wed Oct 16, 2013 4:38 am

Hi,
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.

Image
Image
Image

EDIT:
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.
Last edited by schmutly on Wed Oct 16, 2013 5:46 am, edited 1 time in total.
schmutly
 
Posts: 217
Joined: Fri Feb 20, 2009 4:16 pm

Re: hpwMimeEncodeFile question

Postby dec » Wed Oct 16, 2013 5:43 am

Hello,

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:

http://neoplugins.com/?download/tcpimage.zip

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:
.
Enhance your NeoBook applications!
.
57 plugins, 1113 actions and 230 samples
.
NeoPlugins website: www.neoplugins.com
.
User avatar
dec
 
Posts: 1663
Joined: Wed Nov 16, 2005 12:48 am
Location: Spain

Next

Return to PlugIn Discussions

Who is online

Users browsing this forum: No registered users and 1 guest