4

我有一个存储在 MSSQL 中的位图图像,列的数据类型是 varbinary(3072)。我想要在 PHP 中对图像做的就是显示它+将它存储到一个文件中。怎么做?

在 Google 和 SO 上都找不到任何有用的东西。我唯一发现的是使用了一些框架——这不是我想要的。

这是一个示例图像:

0x444453207C0000000710080010000000100000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000400000044585431000000000000000000000000000000000000000000000000000000000000000000000000000000001B021A02555555551B021A02555555551B021A02555555551B021A02555555559DBFA7110D3FD555FFFF115E02080F05FEDF4E03C0A0E070555DE819635EFAC3F69DE609DC706BEFFCBFA4010B0BADDDFBC74F4458B808A8B475271A60ACA67757AFA9335F7E5456ED3345091BA280A058972C3BE063E9F5104D683A55FD8383
4

1 回答 1

5

好吧,这是答案(谢谢 NullUserException ఠ_ఠ):

header('Content-Type: image/bmp');
$h2 = '424D36030000000000003600000028000000100000001000000001001800000000000003000000000000000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA0D2FD3BA5FC39A9FC4BABFC77BDFD50ADFC38A5FC37A5FC4DACFC87C6FDE3F2FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFDBEEFE39A3FC4CCDFE56D7FE3FC0FD57D8FE61E3FF61E3FF59DAFE3DBDFD289DFBABD7FEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF91CAFD2BAAFC6CEFFF6BEDFF46C4E83AB6E13AB6E140BDE46CEEFF59DBFE209EFCACD7FEFFFFFFFFFFFFFFFFFFEBF6FF30A0FB55D6FE63E5FC28A2D528A2D539B6E139B6E11C94CD1287C565E7FC5ADBFE249AFBE5F3FFFFFFFFFFFFFF93CBFD3ABAFD6CEEFF28A2D555D5F466E8FF66E8FF66E8FF66E8FF49C8EC1C94CD6CEEFF3DBDFD86C5FDFFFFFFFFFFFF52AEFC55D6FE69ECFF66E8FF66E8FF66E8FF66E8FF66E8FF66E8FF66E8FF44C2E869EBFF58DAFE4BABFCFFFFFFFFFFFF37A4FC5FE1FF68EAFF8CEEFFD9F9FFBCF5FF66E8FF66E8FFBCF5FFD9F9FF8CEEFF67E9FF62E3FF35A4FBFFFFFFFFFFFF36A3FC5FE1FF7AEDFFFFFFFF6F6F6F5F5F5F9FF1FF9FF1FF6F6F6F4F4F4FFFFFFF79ECFF61E3FF36A5FBFFFFFFFFFFFF54AFFC54D5FE85F0FFFFFFFF0F0F0F000000A9F2FFA9F2FF0F0F0F000000EFEFEF85EFFF58D9FE4CACFCFFFFFFFFFFFF97CDFD38B8FD6CEEFFF5FEFF9F9F9F9F9F9F82ECFF82ECFF9F9F9F8F8F8FF5FEFF6CEEFF3BBBFD8AC7FDFFFFFFFFFFFFEDF7FF2B9CFB50C9EF6CB5BFACE5EFB2F3FF66E8FF66E8FF95EFFFB2F3FF86F1FF58D9FE269AFBE8F4FFFFFFFFFFFFFFFFFFFFBBDFFE1C7FCD0000000E1E2049A3B068EAFF5BCEE050B2C03D87901029301B80CEB5DCFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFBADEFE165A951C5C7F35869F59D4F0429BB015364019526F135286B2DAFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFECF6FF98CDFD57B0FC38A4FC37A4FC55AFFC93CBFDEAF5FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF';
$s = pack('H*', strtolower($h2));
echo $s;

唯一的问题是我发布的图像似乎是某种奇怪的格式。

于 2011-10-15T22:41:06.440 回答