chaitu111 / timthumb

Automatically exported from code.google.com/p/timthumb
0 stars 0 forks source link

Canvas Color fix #333

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
The following changes are required to fill with the correct solid canvas color 
when using zc=2

//Blue isn't being picked up correctly, it's picking the Green values
$canvas_color_B = hexdec (substr ($canvas_color, 2, 2));
Should be:
$canvas_color_B = hexdec (substr ($canvas_color, 4, 2));

//Canvas always appears black regardless of default canvas colour
$color = imagecolorallocatealpha ($canvas, $canvas_color_R, $canvas_color_G, 
$canvas_color_B, 127);
should be:
$color = imagecolorallocatealpha ($canvas, $canvas_color_R, $canvas_color_G, 
$canvas_color_B, 0);

Original issue reported on code.google.com by sim...@ringalpha.com on 5 Feb 2012 at 3:43

GoogleCodeExporter commented 8 years ago
I agree with :
$canvas_color_B = hexdec (substr ($canvas_color, 2, 2));
Should be:
$canvas_color_B = hexdec (substr ($canvas_color, 4, 2));

But on the background color, it must have an alpha channel to 127 :
$color = imagecolorallocatealpha ($canvas, $canvas_color_R, $canvas_color_G, 
$canvas_color_B, 127);

Original comment by neopheus on 6 Feb 2012 at 7:40

GoogleCodeExporter commented 8 years ago
For me, the alpha of 127 only renders black. e.g., if I set the RGB to ff00ff 
to expose issues the expected magenta never appears and I see black around the 
edges. Even the default white (ffffff) doesn't appear if you leave everything 
alone and just set 'zc=2'.
If the alpha is set to 0, then I get a solid fill of the canvas color I expect.

Original comment by sim...@ringalpha.com on 6 Feb 2012 at 9:03

GoogleCodeExporter commented 8 years ago
thanks for the feedback - I hadn't noticed that issue with the colours so I 
have implemented the fix.

My test suite was using red and grey :S

I am now using red, green, blue, yellow, cyan, and magenta - so should pick it 
up if this happens again.

Original comment by BinaryMoon on 7 Feb 2012 at 1:30