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 webAPI接口返回值判断
  • ¥15 自动化测试 UI Automtion
  • ¥20 关于#深度学习#的问题:2708)输出:邻接矩阵A 或者 节点索引方式:通过随机游走或者其他方式,保持节点连接类似下图(语言-python)
  • ¥15 win2012 iscsi ipsec
  • ¥15 封装的 matplotlib animation 不显示图像
  • ¥15 python摄像头画面无法显示
  • ¥15 关于#3d#的问题:d标定算法(语言-python)
  • ¥15 cve,cnnvd漏洞扫描工具推荐
  • ¥15 图像超分real-esrgan网络自己训练模型遇到问题
  • ¥15 如何构建全国统一的物流管理平台?