Javascript/HTML 如何将 JOT 格式的内容更改为 GIF 格式
我有一个生成签名的应用程序。它是 JOT 格式: http://aspn.activestate.com/ASPN/CodeDoc/JOT/ JOT/GD.html
如何编写 JavaScript 函数将其转换为 GIF 格式。
我已经得到了这个 C 示例,但我不知道如何转换它。
谢谢。
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);
}
}
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);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在您的代码示例中,所有有趣的事情都发生在这里:
实际的转换是通过此
jotogif
方法完成的。代码示例的其余部分几乎无关紧要,只是打开文件等,但不操作图像。这实际上并不是 JavaScript 非常适合做的事情。我会创建一个网络服务来处理转换。然后 JavaScript 将 JOT 文件发送到 Web 服务并获取 GIF 文件作为响应。
Web 服务可以调用可用于此转换的任何现有工具/库。
In your code example, all the interesting stuff happens here:
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.