views:

8

answers:

1

Hi,

I have an application that generates signatures. It is in JOT format: http://aspn.activestate.com/ASPN/CodeDoc/JOT/JOT/GD.html

How do I write a JavaScript function to convert it into GIF format.

I have been given this C example, but I don't know how to convert it.

Thanks.

void doJot2Gif(PODSObject *podsObj,const char* pBase64Data,const char* pFilename)
{
 int len = (int)(strlen(pBase64Data));

 if ( len > 0 ) {

  // make a copy of the JOT data 
  unsigned char* ptrBuff = (unsigned char*)malloc(len+1);
  memset(ptrBuff,0,len+1);
  strcpy((char*)ptrBuff,pBase64Data);

  // append the GIF extension to the filename
  char gif_filepath[256];
  strcpy(gif_filepath,pFilename);
  strcat(gif_filepath,".GIF");
  HANDLE  hFile = FILE_OPEN((char*)gif_filepath);

  if (hFile == INVALID_HANDLE_VALUE) {
   return;
  }

  // call the routine that converts the JOT to the GIF and writes the file
  jottogif((unsigned char*)ptrBuff, hFile);

  free(ptrBuff);
  FILE_CLOSE(hFile);

 }

}
+1  A: 

In your code example, all the interesting stuff happens here:

// call the routine that converts the JOT to the GIF and writes the file
jottogif((unsigned char*)ptrBuff, hFile);

The actual conversion is done by this jottogif method. The rest of your code example is almost irrelevant, just opening files etc. but not manipulating the image.

This isn't really something JavaScript is well suited for doing. I'd create a webservice to handle the conversion. The JavaScript then sends the JOT file to the webservice and gets the GIF file as a response.

The webservice could invoke any existing tools/libraries that are available for this conversion.

Kris
I'll look at using another method to get the file GIFed unless someone can think of an easy way to convert. Shame it uses such an odd format.