2010-07-08 74 views
0

我有一個生成簽名的應用程序。它採用JOT格式: http://aspn.activestate.com/ASPN/CodeDoc/JOT/JOT/GD.htmlJavascript/HTML如何將JOT格式的內容更改爲GIF格式

如何編寫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); 

} 

} 
+0

當你在這個級別工作時,你不能只做一個從C到JavaScript的映射。它們是爲完全不同的事物而設計的。 – Skilldrick 2010-07-08 09:57:42

回答

1

在您的代碼示例中,所有有趣的事情發生在這裏:

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

實際的轉換是通過這種方法jottogif完成。代碼示例的其餘部分幾乎是不相關的,只是打開文件等,但不處理圖像。

這實際上並不是JavaScript適合做的事情。我會創建一個web服務來處理轉換。然後JavaScript將JOT文件發送到Web服務並獲取GIF文件作爲響應。

該webservice可以調用任何現有的工具/庫可用於此轉換。

+0

我會看看使用另一種方法來獲取GIF文件,除非有人能想到一種簡單的轉換方法。羞愧它使用這種奇怪的格式。 – user385579 2010-07-08 10:13:37