2010-02-23 74 views
0

我想能夠顯示在jQuery對話窗口中使用php在飛行中製作的圖像。php圖像創建和jQuery對話框

當我嘗試這一切時,我得到的是圖像的二進制數據。但在正常的php頁面上創建圖像不是問題。

我有一個簡單的PHP腳本來創建圖像

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); 
} 

創造對話的是不是一個問題,輸出HTML。

任何有關如何讓我顯示創建的圖像的建議?

真的希望有人能幫忙嗎?

謝謝

回答

1

負載使用$阿賈克斯圖像(),並注入到DOM:

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

然後顯示您的jQuery的對話框。 Presto!

+0

現在我覺得啞巴!工作了一個魅力謝謝你 – Lee 2010-02-23 02:59:42