iamali84 Posted January 10, 2007 Share Posted January 10, 2007 hey all!i've been using flash to create an online graffiti wall and using PHP to create JPG images of images created on it but am having a bit of a problem. the JPGs are created fine but the colours are coming out wrong, see image below:[url=http://farm1.static.flickr.com/126/352712855_bccd09ca61_b.jpg][img]http://farm1.static.flickr.com/126/352712855_bccd09ca61.jpg[/img][/url]it seems the red and yellow are coming out as blue and light blue. does anyone have any idea why this may be? this is the PHP code i am using:[code]<?php//If GD library is not installed if(!function_exists("imagecreate")) die("Sorry, you need GD library to run this example");//Capture Post data $data = explode(",", $_POST['img']); $width = $_POST['width']; $height = $_POST['height'];//Allocate image $image = (function_exists("imagecreatetruecolor"))?imagecreatetruecolor( $width ,$height ):imagecreate( $width ,$height ); imagefill($image, 0, 0, 0xFFFFFF);//Copy pixels $i = 0; for($x = 0; $x <= $width; $x++){ for($y = 0; $y <= $height; $y++){ while(strlen($data[$i]) < 6) $data[$i] = "0" . $data[$i]; $tmp = "0x" . $data[$i] ; $data[$i] = sprintf("%x", $tmp - 0x1); $r = 255-hexdec("0X".substr( $data[$i] , 0 , 2 )); $g = 255-hexdec("0x".substr( $data[$i] , 2 , 2 )); $b = 255-hexdec("0x".substr( $data[$i++] , 4 , 2 )); $color = ($r << 16) | ($g << 8) | $b; $color = imagecolorallocate($image, $r, $g, $b); imagesetpixel ( $image , $x , $y , $color ); /*if ( ($r < 0 || $r >255) || ($g < 0 || $g >255) || ($b < 0 || $b >255) ) die("something");$ */ } }//Output image and clean header( "Content-type: image/jpeg" ); ImageJPEG( $image ); imagedestroy( $image ); ?>[/code]thanks! Quote Link to comment Share on other sites More sharing options...
taith Posted January 10, 2007 Share Posted January 10, 2007 this is because of eithera) flash is recording vector based art (php doesnt)b) flash works on a different color spectrom (hex, not rgb)or c) .jpg isnt translating the colours properly, try using .png(has more colour supports) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.