powerbuilder中oleblob到位图问题的转换

powerbuilder中oleblob到位图问题的转换,ole,Ole,我需要从旧的db ms sql 6.5执行数据转换,现在我对ms sql 6.5中的映像存储有问题,存储的此映像都是ole数据,这意味着与此ms sql 6.5接口的旧应用程序实际上将映像作为ole存储在映像类型中。当我在powerbuilder中选择blob into a blob时,我需要将此blob发送到ole_1.objectdata,然后将此ole_1.objectdata转换为所需的长度,以便输出到磁盘上的位图文件,我已从Buasuwan发布的将blob打印为bmp/jpg时交换的专

我需要从旧的db ms sql 6.5执行数据转换,现在我对ms sql 6.5中的映像存储有问题,存储的此映像都是ole数据,这意味着与此ms sql 6.5接口的旧应用程序实际上将映像作为ole存储在映像类型中。当我在powerbuilder中选择blob into a blob时,我需要将此blob发送到ole_1.objectdata,然后将此ole_1.objectdata转换为所需的长度,以便输出到磁盘上的位图文件,我已从Buasuwan发布的将blob打印为bmp/jpg时交换的专家中提取了此转换代码,但是,由于帖子是旧帖子,因此无法获取dll。它可以很好地将60%的blob转换为位图,而剩余的blob生成具有相关文件大小的空视图,只是不能仅查看它。下面是代码,我希望那里的一些专家可以帮助我将ole转换为位图

    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
我的女朋友如下


如果它确实是一个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
此时,您有一个包含位图数据的blob


然而,我处理的数据是由MS Paint存储的。我们最近发现,更新版本的MS Paint以WMF格式而不是BMP格式存储数据。在这种情况下,我们要做的是查找OlePres000存储,而不是OLE10本机存储,然后在该存储中输入40个字符,而不是4个字符。

太棒了!你从哪里得到这些细节?你有没有遵循任何关于这方面的文件,或者是如何遵循的关于一般使用OLEStreams和OLEStores的部分来自Sybase文档。其余的则直接检查复合文件,找出它们的结构,然后根据需要解析它们。
// 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