我正在开发一个基于桌面的PHP应用程序,我们需要捕获一个人的图像并使用Zebra GC420t打印机将其打印在标签上预期的图像应该如下图所示.
当我尝试打印时,它会输出如下图所示的输出.
我使用以下代码使用代码将rgb图像转换为图像ditheringphp
$photo_url="";
if(isset($_GET['photo'])){
$photo_url=$_GET['photo'];
}
function image2grf($filename='$photo_url', $targetname = 'R:IMAGE.GRF')
{
$info = getimagesize($filename);
$im = imagecreatefrompng($filename);
$width = $info[0]; // imagesx($im);
$height = $info[1]; // imagesy($im);
$depth = $info['bits'] ?: 1;
$threshold = $depth > 1 ? 160 : 0;
$hexString = '';
$byteShift = 7;
$currentByte = 0;
// iterate over all image pixels
for ($y = 0; $y < $height; $y++) {
for ($x = 0; $x < …Run Code Online (Sandbox Code Playgroud)