1<?php 2 3class OutputDriverFastPSLevel2 extends OutputDriverFastPS { 4 function OutputDriverFastPSLevel2(&$image_encoder) { 5 $this->OutputDriverFastPS($image_encoder); 6 } 7 8 function image($image, $x, $y, $scale) { 9 $this->image_scaled($image, $x, $y, $scale, $scale); 10 } 11 12 function image_scaled($image, $x, $y, $scale_x, $scale_y) { 13 $image_encoder = $this->get_image_encoder(); 14 $lines = $image_encoder->by_lines($image, $size_x, $size_y); 15 16 $offset = 0; 17 foreach ($lines as $line) { 18 $this->moveto($x,$y-$offset*$scale_y); 19 $this->write(sprintf("gsave\n")); 20 $this->write(sprintf(" << /ImageType 1 /Width %d /Height 1 /BitsPerComponent 8 /Decode [0 1 0 1 0 1] /ImageMatrix %s /DataSource %s >> image\n", 21 $size_x, 22 sprintf("matrix currentpoint translate %.2f %.2f scale 0 %.2f translate", 23 $scale_x, $scale_y, 24 $size_y 25 ), 26 "currentfile /ASCIIHexDecode filter")); 27 $this->write(sprintf("%s\n", $line)); 28 $this->write(sprintf("grestore\n")); 29 30 $offset ++; 31 }; 32 } 33 34 function image_ry($image, $x, $y, $height, $bottom, $ox, $oy, $scale) { 35 // Fill part to the bottom 36 $cy = $y; 37 while ($cy+$height > $bottom) { 38 $this->image($image, $x, $cy, $scale); 39 $cy -= $height; 40 }; 41 42 // Fill part to the top 43 $cy = $y; 44 while ($cy-$height < $y + $oy) { 45 $this->image($image, $x, $cy, $scale); 46 $cy += $height; 47 }; 48 } 49 50 function image_rx($image, $x, $y, $width, $right, $ox, $oy, $scale) { 51 // Fill part to the right 52 $cx = $x; 53 while ($cx < $right) { 54 $this->image($image, $cx, $y, $scale); 55 $cx += $width; 56 }; 57 58 // Fill part to the left 59 $cx = $x; 60 while ($cx+$width >= $x - $ox) { 61 $this->image($image, $cx-$width, $y, $scale); 62 $cx -= $width; 63 }; 64 } 65 66 function image_rx_ry($image, $x, $y, $width, $height, $right, $bottom, $ox, $oy, $scale) { 67 // Fill bottom-right quadrant 68 $cy = $y; 69 while ($cy+$height > $bottom) { 70 $cx = $x; 71 while ($cx < $right) { 72 $this->image($image, $cx, $cy, $scale); 73 $cx += $width; 74 }; 75 $cy -= $height; 76 } 77 78 // Fill bottom-left quadrant 79 $cy = $y; 80 while ($cy+$height > $bottom) { 81 $cx = $x; 82 while ($cx+$width > $x - $ox) { 83 $this->image($image, $cx, $cy, $scale); 84 $cx -= $width; 85 }; 86 $cy -= $height; 87 } 88 89 // Fill top-right quadrant 90 $cy = $y; 91 while ($cy < $y + $oy) { 92 $cx = $x; 93 while ($cx < $right) { 94 $this->image($image, $cx, $cy, $scale); 95 $cx += $width; 96 }; 97 $cy += $height; 98 } 99 100 // Fill top-left quadrant 101 $cy = $y; 102 while ($cy < $y + $oy) { 103 $cx = $x; 104 while ($cx+$width > $x - $ox) { 105 $this->image($image, $cx, $cy, $scale); 106 $cx -= $width; 107 }; 108 $cy += $height; 109 } 110 } 111} 112 113?>