reduced polygon shape coords of the only colored pixelarea of transparent PNG
I need HTML polygon shape coordinates of the only colored pixel area from thousands of transparent PNGs.
I know that I can check each pixel with PHP to see if it is transparent or not. But thi开发者_运维技巧s method would give me thousands of points which would slow down my JavaScript I will use later on.
So I need the reduce the amount of points of the resulting polygon in a way Fireworks does it if it creates a Hotspot of a selection. Does anyone know of a function or an existing PHP script or JavaScript to do this?
I have also tried to find a way to automate this in Fireworks and Photoshop, but it seems that these functions cannot be used this way.
Whilst a crude solution, you could simply sample the source image's alpha channel at a lower "resolution". (i.e.: Simply check every 10 or 20 pixels in a x/y grid rather than each pixel location.)
This won't be that accurate, but may well suffice for the purposes you require.
精彩评论