Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Aufruf: php lcdgen.php schwarzweissbild.png on.png off.png zieldateiname.png
- $im = imagecreatefromstring(file_get_contents($argv[1]));
- $on = imagecreatefromstring(file_get_contents($argv[2]));
- $off = imagecreatefromstring(file_get_contents($argv[3]));
- $imsize = getimagesize($argv[1]);
- $onoffsize = getimagesize($argv[2]);
- $result = imagecreatetruecolor($imsize[0] * $onoffsize[0], $imsize[1] * $onoffsize[1]);
- for ($y = 0; $y < $imsize[1]; $y++) {
- for ($x = 0; $x < $imsize[0]; $x++) {
- $black = (imagecolorat($im, $x, $y) == 0);
- echo $black ? "1" : "0";
- imagecopy(
- $result,
- $black ? $on : $off,
- // dest_x, dest_y,
- $x * $onoffsize[0], $y * $onoffsize[1],
- // src_x, src_y, src_w, src_h
- 0, 0, $onoffsize[0], $onoffsize[1]
- );
- }
- echo "\n";
- }
- imagepng($result, $argv[4]);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement