hi guys...could someone help me try to recode my php code below from generating just a black and white image. the code below takes time to process cause its trying to generate as much colors as it could receive from its source, but the thing is, the source is just passing black and white colors...
thanks in advance!
<?php
//error_reporting(0);
$w = (int)$_POST['width'];
$h = (int)$_POST['height'];
$fname = $_POST['file'];
$img = imagecreatetruecolor($w, $h);
imagefill($img, 0, 0, 0xFFFFFF);
$rows = 0;
$cols = 0;
for($rows = 0; $rows < $h; $rows++){
$c_row = explode(",", $_POST['px' . $rows]);
for($cols = 0; $cols < $w; $cols++){
$value = $c_row[$cols];
if($value != ""){
$hex = $value;
while(strlen($hex) < 6){
$hex = "0" . $hex;
}
$r = hexdec(substr($hex, 0, 2));
$g = hexdec(substr($hex, 2, 2));
$b = hexdec(substr($hex, 4, 2));
$test = imagecolorallocate($img, $r, $g, $b);
imagesetpixel($img, $cols, $rows, $test);
}
}
}
$fileName = $fname.".jpg";
$data = imagejpeg($img, $fileName, 95);
?>