/** * Function: drawImage * * Draws a given image. */ function drawImage($x, $y, $w, $h, $image, $aspect = true, $flipH = false, $flipV = false) { $img = $this->loadImage($image); if ($img != null) { $iw = imagesx($img); $ih = imagesy($img); // Horizontal and vertical image flipping if ($flipH || $flipV) { $img = mxUtils::flipImage($img, $flipH, $flipV); } // Preserved aspect ratio if ($aspect) { $s = min($w / $iw, $h / $ih); $x0 = ($w - $iw * $s) / 2; $y0 = ($h - $ih * $s) / 2; imageCopyResized($this->image, $img, $x0 + $x, $y0 + $y, 0, 0, $iw * $s, $ih * $s, $iw, $ih); } else { imageCopyResized($this->image, $img, $x, $y, 0, 0, $w, $h, $iw, $ih); } } }