2011-10-19 10 views
0

古いdb ms sql 6.5からデータ変換を実行する必要があります。これはms sql 6.5内のイメージストアに問題があります。このイメージは古いデータを意味します。このmsql 6.5インターフェイスのアプリケーションでは、画像タイプにoleとしてイメージを格納します。私はselectbulobをpowerbuilderのblobに入れると、このブロブをole_1.objectdataに送り、次にこのole_1.objectdataをディスク上のビットマップファイルに出力するために必要な長さに変換する必要があります。この変換コードはexpert- 「Blobをbmp/jpgに印刷する」で交換されました(しかしBuasuwanによって投稿されましたが、ポストが古い投稿であるためdllを取得できません)。私のBLOBの60%がビットマップに変換されていますが、残りの部分は関連するファイルサイズの空のビューを生成し、それを見ることはできません。コードは、ビットマップへのOLEの翻訳を助けることができます。OLE BLOBからPowerBuilderのビットマップへの変換

Blob lb_image 

    SelectBLOB picture_image into :lb_image 
    from individual 
    where individual_object_id='200506061121430020' 
    using SQLCA; 

    if SQLCA.sqlcode<>0 then 
     messagebox("cannot connect","cannot connect") 
    end if 


    if(len(lb_image)>0) then 


    ole_1.objectdata=lb_image 


    gf_convertbmp(ole_1.objectdata,ls_path) 


    end if 

私gf_convertbmp

long   ll_index, ll_len, ll_length 
    integer  li_FileNum 

    // Find Keyword 'BM' for starting Bitmap File 


    ll_len = Len(lb_ole_data) 

    ll_index = 1 

    blob  lb_bm 
    lb_bm = blob('BM') 
    do while ll_index <= ll_len 

     if BlobMid(lb_ole_data, ll_index, 2) = lb_bm then 

     exit 
     end if 

     ll_index++; 
    loop 

    // Find Length of Image 


     ll_length = long(asc(char(BlobMid(lb_ole_data, ll_index - 4, 1)))) + & 
       long(asc(char(BlobMid(lb_ole_data, ll_index - 3, 1)))) * 256 + & 
       long(asc(char(BlobMid(lb_ole_data, ll_index - 2, 1)))) * 65536 

     // Save Bitmap to File 


     li_FileNum = FileOpen(filename, StreamMode!, Write!, LockWrite!, Replace!) 


     // Write Bitmap Data 


    do while ll_length > 0 
      if ll_length > 32000 then 
      FileWrite(li_FileNum, BlobMid(lb_ole_data, ll_index, 32000)) 
      else 
      FileWrite(li_FileNum, BlobMid(lb_ole_data, ll_index, ll_length)) 
      exit 
      end if 
     ll_index += 32000 
     ll_length -= 32000 
     loop 



     FileClose(li_FileNum) 

答えて

0

を次のようにそれは本当にOLEは、ビットマップを包んであれば、あなたが最善のアプローチは、(少なくとも私が使用するもの)はOLESTREAMとしてデータを開くことですね、そのデータを含むストリーム内のOle10Nativeストレージを探します。あなたはビットマップデータ

とブロブを持っているこの時点で

// ls_storage is filename where data is written out 
ll_rc = lole_storage.Open (ls_storage) 

//Check to see that the Ole10Native storage exists. 
ls_streamname = Char(1) + 'Ole10Native' 
lole_storage.MemberExists (ls_streamname, lb_objectexists)   
IF lb_objectexists THEN 
    //Start 4 bytes into the storage to get the file 
    li_startat = 4    
ELSE 
    Return -1 
END IF 

ll_rc = lole_stream.Open(lole_storage, ls_streamname, stgRead!, stgExclusive!) 

//Get the length of the OLE stream 
ll_rc = lole_stream.Length (ll_streamlen) 


//Determine how many times to call Read 
//read returns a maximum or 32765 characters at a time 
//We are going to Seek to the first position, so don't include it in the 
//calculations. Also note that the Seek is zero-indexed, so we remove one 
//from the startat for our calcs 
ll_streamlen = ll_streamlen - (li_startat - 1) 
IF ll_streamlen > ll_chunk THEN 
    IF Mod(ll_streamlen, ll_chunk) = 0 THEN 
     ll_loops = ll_streamlen/ll_chunk 
    ELSE 
     ll_loops = (ll_streamlen/ll_chunk) + 1 
    END IF 
ELSE 
    ll_loops = 1 
END IF 


//Read the OLE stream, starting at the requested position 
ll_newpos = li_startat 
FOR ll_i = 1 to ll_loops 
    lole_stream.Seek (ll_newpos) 
    ll_rc = lole_stream.Read(lblob_temp, ll_chunk) 
    IF ll_i = 1 THEN 
     ablb_dataout = lblob_temp 
    ELSE 
      ablb_dataout = ablb_dataout + lblob_temp 
    END IF 
    ll_newpos = ll_newpos + ll_chunk 
NEXT 

しかし、私が取り組んできたデータは、MSペイントで保存しました。私たちが最近発見したのは、新しいバージョンのMS PaintがBMPではなくWMF形式でデータを保存するということです。その場合、Ole10NativeストレージではなくOlePres000ストレージを探し、そのストレージに40文字を4ではなく開始します。

+0

素晴らしいです!これらの詳細はどこで手に入れますか?あなたはどのようにこれに関する文書をたどったのですか? :) – somnath

+0

OLEStreamsとOLEStoresの一般的な使い方は、Sybaseのドキュメントにあります。残りの部分は複合ファイルを直接調べ、構造を把握してから解析する必要がありました。 –

関連する問題