dongyuanliao6204 2010-02-23 02:51
浏览 21
已采纳

php image create和jquery对话框

I want to be able to show an image made on the fly with php in jQuery Dialog window.

When I try this all I get is the binary data for the image. But creating the image on a normal php page is not a problem.

I have a simple php script to create the image

 public function image()
{
    header('Content-type: image/png');

    // Create the image
    $im = imagecreatetruecolor(400, 400);

    // Create some colors
    $white = imagecolorallocate($im, 255, 255, 255);
    $grey = imagecolorallocate($im, 128, 128, 128);
    $black = imagecolorallocate($im, 0, 0, 0);
    imagefilledrectangle($im, 0, 0, 399, 399, $white);

    // The text to draw
    $text = 'Just some simple text...';

    $font = 'arial.ttf';

    // Add some shadow to the text
    imagettftext($im, 20, 0, 10, 40, $grey, $font, $text);

    // Add the text
    imagettftext($im, 20, 0, 10, 20, $black, $font, $text);

    // Using imagepng() results in clearer text compared with imagejpeg()
    imagepng($im);
    imagedestroy($im);
}

Creation of the dialog is not a problem and outputting html.

Any suggestion on how I can get this to show my created image ?

Really hope someone can help?

Thank you

  • 写回答

1条回答 默认 最新

  • duanche9384 2010-02-23 02:55
    关注

    Load the image using $.ajax() and inject into DOM:

    $.load('#yourDialogContentDiv').html('<img src="http://YOUR_PHP_IMAGE_GENERATOR_SCRIPT" />'));
    

    Then show your jQuery dialog. Presto!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 opencv图像处理,需要四个处理结果图
  • ¥15 无线移动边缘计算系统中的系统模型
  • ¥15 深度学习中的画图问题
  • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条
  • ¥15 Python报错怎么解决
  • ¥15 simulink如何调用DLL文件
  • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
  • ¥30 线性代数的问题,我真的忘了线代的知识了
  • ¥15 有谁能够把华为matebook e 高通骁龙850刷成安卓系统,或者安装安卓系统
  • ¥188 需要修改一个工具,懂得汇编的人来。