示例#1
0
 /**
  * Mixes a transparent background with a resized foreground preview
  *
  * @param \OC_Image $previewData
  * @param int $previewWidth
  * @param int $previewHeight
  * @param int $newWidth
  * @param int $newHeight
  * @param int $maxWidth
  * @param int $maxHeight
  * @param int $newX
  * @param int $newY
  *
  * @return resource
  */
 private function processPreview($previewData, $previewWidth, $previewHeight, $newWidth, $newHeight, $maxWidth, $maxHeight, $newX, $newY)
 {
     $fixedPreview = imagecreatetruecolor($maxWidth, $maxHeight);
     // Creates the canvas
     // We make the background transparent
     imagealphablending($fixedPreview, false);
     $transparency = imagecolorallocatealpha($fixedPreview, 0, 0, 0, 127);
     imagefill($fixedPreview, 0, 0, $transparency);
     imagesavealpha($fixedPreview, true);
     imagecopyresampled($fixedPreview, $previewData->resource(), $newX, $newY, 0, 0, $newWidth, $newHeight, $previewWidth, $previewHeight);
     return $fixedPreview;
 }