kernelgpf Posted July 16, 2007 Share Posted July 16, 2007 See, I have this script made for watermarks that layers two images together, here: http://dragon-dynasty.com/script2.php Now, I need to add code somewhere [where? =x] to have a certain color that I need to be able to specify transparently color over JUST the dragon. Any ideas? Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted July 16, 2007 Share Posted July 16, 2007 Why don't you add the color to the dragon before merging it with the other image? That way you don't have to worry about trying to just color a specific part of the image when it is already merged together. This page has a lot of useful functions that will help you with the coloring part: http://php.net/imagecolorallocate Quote Link to comment Share on other sites More sharing options...
kernelgpf Posted July 17, 2007 Author Share Posted July 17, 2007 Because the color of the dragon depends on a hex code inserted in the DB: it needs to be dynamically colored. Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted July 17, 2007 Share Posted July 17, 2007 Yeah, there are functions on that URL I gave you that can color by hex code, so it would be perfect for what you are doing. So first call the function to color the dragon, THEN merge it with the other image, that way the dragon will be already colored when they merge together. Quote Link to comment Share on other sites More sharing options...
kernelgpf Posted July 17, 2007 Author Share Posted July 17, 2007 It doesn't say anywhere on the page how to color ONLY CERTAIN PARTS of the image, though. That's my problem. Quote Link to comment Share on other sites More sharing options...
kernelgpf Posted July 17, 2007 Author Share Posted July 17, 2007 I need Barand's help, but he won't reply to my PM. -laughs- Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted July 17, 2007 Share Posted July 17, 2007 Lmao, it's probably because messaging people for help is against the rules, the moderators take that pretty seriously =/ Wait, so now you are only wanting to color certain parts of the dragon? I thought that you were wanting the dragon just one color but you didn't know how to color the dragon without coloring the other image you just merged with it as well. I'm confused... Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted July 17, 2007 Share Posted July 17, 2007 I think I found what you are looking for xD imagefilledarc() http://www.php.net/manual/en/function.imagefilledarc.php It allows you to specify coordinates and a color for the area you are trying to color. Quote Link to comment Share on other sites More sharing options...
Barand Posted July 17, 2007 Share Posted July 17, 2007 I need Barand's help, but he won't reply to my PM. -laughs- I don't recall any recent PM's from you, but I do remember PMing you to follow up on a solution I gave you, just to check if it worked OK, and not receiving any reply. So I may have just binned your latest request. Quote Link to comment Share on other sites More sharing options...
kernelgpf Posted July 18, 2007 Author Share Posted July 18, 2007 Eh, I wasn't aware of that. I just replied to a PM he sent me. Sorry. x.x No- that's feature draws an arc. On the BASE DRAGON image, I need JUST the dragon's lines filled in with a hex color I will specify. Barand- you gave me a script that'll replace all of a certain color with a different color- would you happen to still have that script, I think I've misplaced it. Quote Link to comment Share on other sites More sharing options...
Barand Posted July 18, 2007 Share Posted July 18, 2007 Was it this one <?php $skinfile = isset($_GET['skin']) ? $_GET['skin'] : 'bluetexture.gif'; $skin = imagecreatetruecolor(500,508); $tile = imagecreatefromgif($skinfile); imagesettile($skin, $tile); imagefill($skin, 250, 205, IMG_COLOR_TILED); /** * convert dragon png to truecolor */ $im = imagecreatetruecolor(500,508); $dragon = imagecreatefrompng('reddragon.png'); imagecopy($im,$dragon,0,0,0,0,500,508); /** * select color to be replaced by skin */ $red = imagecolorat($im, 255,400); for ($x=0; $x<500; $x++) { for ($y=0; $y<508; $y++) { if (imagecolorat($im,$x,$y) == $red) { $skinpix = imagecolorat($skin,$x,$y); imagesetpixel($im,$x,$y,$skinpix); } } } header("content-type: image/png"); imagepng($im); imagedestroy($im); imagedestroy($skin); imagedestroy($dragon); imagedestroy($tile); ?> Quote Link to comment Share on other sites More sharing options...
kernelgpf Posted July 18, 2007 Author Share Posted July 18, 2007 Yup, that's it. I'll have the base dragon images painted red, and have it substitute the hex color for the file. =P Thanks again, Barand. 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.