Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by SiliconMind

  1. Unfortunately I'm limited to .NET 2.0 so probably most of your optimisations wont work for me Anyway, I would love to see your new code. Are you planing to include sources?
  2. Hmm, it seems that if users selects "Keep original image", then you just skip invisible parts of the shadow - this speeds things dramatically. Is that correct?
  3. Kris, I am trying to write my own drop shadow effect (mainly for learning and my own project needs). Drawing the shadow itself is quite easy and I can do it really fast even for larger bitmaps with irregular shapes (in fact bitmap contents doesn't matter). But the real bottleneck is the "grow shadow" part. Users can achieve great results with it, but my algorithm is too damn slow. So, I was hoping to take a look at your "beautiful" source code but it seems that you don't provide it any more. Can you please at least share the idea behind your "grow shadow" routine? My first approach was similar to the convolution filters. I was running second loop inside LockBits for the shadow bitmap and painted additional pixels if they were close enough to the source pixel. When I used the Pythagorean theorem to calculate the distance I got really nice, smooth edged expanded shadow (this way one pixel changes into round-shaped group of pixels). But It's too slow. So I decided to cheat and did the same thing you can do when you optimise the Gaussian filter, that is run the loop with two one-dimensional arrays (I'm sure you are familiar with that, so won't dwell into). That worked in terms of speed, but shape of the resulting shadows is rather poor - obviously I got squared edges. I'm able to compensate that a little when I make pixels a bit transparent if they are far from matrix centre. But that's still far away from perfectly shaped circles that I get with 2D matrix and Pythagorean theorem. I know that I could probably speed things a little if I build my shadow map using byte array (shadow is in fact a transparency mask anyway) instead of bitmap, but I don't think that's going to get me closer to the speed you get So, is there any chance to see your code or at least have some guidelines?
  • Create New...