dqeznd1697 2018-10-08 19:16
浏览 100
已采纳

Imagen,HEX到Byte和Byte到HEX并显示img。 Visual Basic到PHP

I have to pass a function in visual basic to PHP to read this image saved in MySQL. I have tried several things but I did not do it in the database MySql it is currently saved: https://www.pastiebin.com/5bbba9dbc63f6#&togetherjs=73xi1xwALu

    'Save string a Byte in MySql
Public Function StringaByte(cTexto As String) As Byte()
Dim aByte() As Byte
Dim aHexa() As String
Dim i As Long

aHexa = Split(cTexto, "&H")
ReDim aByte(UBound(aHexa) + 1) As Byte
For i = 0 To UBound(aHexa) - 1  
    DoEvents
    aByte(i) = CLng("&H" & aHexa(i + 1))  
Next

StringaByte = aByte
End Function  

'Load hexa in MySql an conver to Byte
Private Function ByteaString(aByte() As Byte) As String
Dim i As Long
Dim cHex As String
cHex = ""
For i = 0 To UBound(aByte)
    DoEvents
    cHex = cHex & "&H" & Hex(aByte(i))    
Next

ByteaString = cHex 
End Function

in PHP I tried function hex2bin and pack

<?php
//header("Content-type: image/gif"); 
header("Content-type: image/jpg"); 

$img2="CODE HEXA IN LINK";

function hextobin($hexstr){ 
    $aHexa = explode("&H", $hexstr);
    $count=count($aHexa);  
    $aByte="";
    for ($x=0;$x<$count; $x++){
        @$aByte .="&H".hex2bin($aHexa[$x]);
    }
    return $aByte;
 }  

$acomulo= hextobin($img2) ;
echo base64_decode($acomulo);exit; 
//echo $acomulo;exit; 

?>

other example in php

 <?php
$img2="CODE HEXA IN LINK";

    function hextobin($hexstr) {
        $aHexa = explode("&H", $hexstr);
        $count = count($aHexa);
        $aByte = "";
        for ($x = 0; $x < $count; $x++) {;
            @$aByte .=pack("H*", $aHexa[$x]);
        }
        return @$aByte;
    }
    $acomulo = hextobin($img2);
    header("Content-type: image/gif");
    echo base64_decode($acomulo);
    exit;

?>
  • 写回答

1条回答 默认 最新

  • doujing1858 2018-10-16 20:24
    关注

    The visual functions do not generate an original 100 percent hexadecimal.

    function vb6toIMG($func_string){
    $func_string=substr($func_string,2);
        //die($func_string);
    
        $arrayHex=explode ("&H",$func_string);
        $str="";
        foreach($arrayHex as $ind=>$dato){
                $str.=chr(hexdec($dato));
        }   
            return $str;
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置