php代码里 实现图片读取 求大神指点,感激不尽!

我在一个A.php文件里画了一张图片
$drawing = new BCGDrawing('', $color_white);
if($drawException) {
$drawing->drawException($drawException);
} else {
$drawing->setBarcode($code);
$drawing->draw();
}
// Header that says it is an image (remove it if you save the barcode to a file)
header('Content-Type: image/png');
header('Content-Disposition: inline; filename="barcode.png"');
// Draw (or save) the image into PNG format.
$drawing->finish(BCGDrawing::IMG_FORMAT_PNG);

我想在另一个文件B.php里,将这张图片显示出来,不知道怎么写?
下面是调用的语句,将图片显示在目标位置里,我是新手,下面的这句话给的是一个绝对路径里保存的图片,如果我想将A.php里的图片显示到这,怎么修改?求大神指点,感激不尽!
$pdf->Image('c:\\xampp\\htdocs\\prototype_system\\img\\m_logo_powertrain.PNG',48,0,30,12,'','');

header('Content-Type: image/png');

你A里面已经输出文件了
b里 <img src=a.php>不就对了追问

能不能回答仔细点 ,比如A的路径在c:\\xampp\\htdocs\\prototype_system\\A.php,
我调用时
$pdf->Image('c:\\xampp\\htdocs\\prototype_system\\img\\m_logo_powertrain.PNG',48,0,30,12,'','');
这句怎么修改?谢谢!新手,没办法

追答

首先你干嘛用绝对路径?

如果你都知道绝对路径了 调用就和php没关系了
比如
test.html
内容为

不就显示了
php一般作为流来显示图片才用到

Header("Content-type: image/PNG");
$im = imagecreate(40,40);
ImagePNG($im);
ImageDestroy($im);

比如这样

追问

不是要绝对路径,只是想知道这句调用语句怎么修改,$pdf->Image('c:\\xampp\\htdocs\\prototype_system\\img\\m_logo_powertrain.PNG',48,0,30,12,'','');本来这句的作用是将本地的一个图片插入进去了,我现在应该怎么修改这句话,在B中插入A中生成的图片?大神

追答

假设你的文件在prototype_system目录 图片在img

那么$pdf->Image(dirname(__FILE__)."/img/m_logo_powertrain.PNG',48,0,30,12,'','');

温馨提示:答案为网友推荐,仅供参考