tag:blogger.com,1999:blog-563071785757928434.post6872582831996095533..comments2024-02-21T08:31:04.853+01:00Comments on Kodierer [Coder]: Rounder, Faster, Better - WriteableBitmapEx 0.9.0.0Rene Schultehttp://www.blogger.com/profile/12777157871967896549noreply@blogger.comBlogger9125tag:blogger.com,1999:blog-563071785757928434.post-72284333696491210822010-02-16T00:18:46.137+01:002010-02-16T00:18:46.137+01:00Hi Balint,
thanks for the suggestion. I somehow m...Hi Balint,<br /><br />thanks for the suggestion. I somehow missed this when I optimized the methods with Buffer.BlockCopy. But I use the even faster Clear() method most of the time.<br />Thanks again.Rene Schultehttps://www.blogger.com/profile/12777157871967896549noreply@blogger.comtag:blogger.com,1999:blog-563071785757928434.post-14830402652672986452010-02-16T00:00:32.877+01:002010-02-16T00:00:32.877+01:00Hello Rene,
Clear would be somewhat better like t...Hello Rene,<br /><br />Clear would be somewhat better like this:<br /><br />public static void Clear(this WriteableBitmap bmp, Color color)<br /> {<br /> int col = (color.A << 24) | (color.R << 16) | (color.G << 8) | color.B;<br /> int[] pixels = bmp.Pixels;<br /> int w = bmp.PixelWidth;<br /> int h = bmp.PixelHeight;<br /> for (int i = 0; i < w; i++)<br /> {<br /> pixels[i] = col;<br /> }<br /> for (int j = 1; j < h; j++)<br /> {<br /> Buffer.BlockCopy(pixels, 0, pixels, j * w * SizeOfARGB, w * SizeOfARGB); <br /> }<br /> }<br /><br />Cheers, BalintAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-563071785757928434.post-11483130233631680362010-02-09T19:33:38.155+01:002010-02-09T19:33:38.155+01:00Thanks Nikola and great finding with the Photoshop...Thanks Nikola and great finding with the Photoshop blend modes.<br />Good that I was able to convince you that pixel shaders are faster than Bitmap operations in Silverlight, although they run on the CPU. :) But as you know hey're implemented efficiently using SSE. I like your idea with the Shader effects in your Image editor, which is awesome. Kudos my friend.<br />It would be great if we were able to apply shaders directly to a WriteableBitmap without the additional Image and Effect classes.Rene Schultehttps://www.blogger.com/profile/12777157871967896549noreply@blogger.comtag:blogger.com,1999:blog-563071785757928434.post-14147199247527029572010-02-09T00:21:35.881+01:002010-02-09T00:21:35.881+01:00Just found that - all Photoshop blend modes in pix...Just found that - all Photoshop blend modes in pixel shaders:<br />http://blog.mouaif.org/?p=94<br /><br />looks very interesting! :)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-563071785757928434.post-15721970355999010712010-02-08T23:58:59.824+01:002010-02-08T23:58:59.824+01:00@Rene:
Great job! I liked the growing tree and cur...@Rene:<br />Great job! I liked the growing tree and curved sample a lot! Also perf looks quite nice :)<br /><br />@Michaud: if you're looking for layer (complete bitmap) blending, maybe you could try blending in pixel shaders after you draw in the current layer. I've been experimenting with this a bit now. Here's a sample code to do overlay blend in pixel shaders. Since overlay blend is one of the more complex ones, there's also a multiply and additive one:<br /> // overlay blend<br /> float4 backColor = tex2D(input, uv);<br /> float4 colorM = color*backColor; // multiply blending<br /> float4 colorS = 1 - (1-color)*(1-backColor); // screen blending<br /> float4 colorO = backColor * colorS + (1-backColor)*colorM; // overlay blending<br /> <br /> // mix with original<br /> return colorO*amount+backColor*(1-amount);Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-563071785757928434.post-13855761974318949352010-01-29T13:45:28.711+01:002010-01-29T13:45:28.711+01:00That's great. Please keep me updated on your p...That's great. Please keep me updated on your progress or if you need some help.<br />The CodePlex project's site discussion is a good place:<br />http://writeablebitmapex.codeplex.com/Thread/List.aspx<br /><br />The method needs a bit of redesign to work with a BlendFunction. You can leave the different hierarchies of the if-statements out. If you look closely at them there are some tests for the alpha values to optimize things a bit. <br />In the first step I would rewrite the if-statements so the BlendMode checks are all in one hierarchy. After that I would extract each BlendMode in a separate method in a class called BlendFunctions or something.Rene Schultehttps://www.blogger.com/profile/12777157871967896549noreply@blogger.comtag:blogger.com,1999:blog-563071785757928434.post-52677164165299420392010-01-29T13:33:26.041+01:002010-01-29T13:33:26.041+01:0020 blend modes? yes, yes, Of course I do :) for a ...20 blend modes? yes, yes, Of course I do :) for a sort of Photoshop / layer experiment application. <br />Would the calling of a function not even out against all the if statements? I'll give it a tryAnonymoushttps://www.blogger.com/profile/17276888582260272949noreply@blogger.comtag:blogger.com,1999:blog-563071785757928434.post-61040351087996797292010-01-29T13:13:46.648+01:002010-01-29T13:13:46.648+01:00Thanks.
I know what you mean. And one might consid...Thanks.<br />I know what you mean. And one might consider to add an overload that uses a delegate like this:<br />Blit(this WriteableBitmap bmp, Rect destRect, WriteableBitmap source, Rect sourceRect, Color color, Func<int, int, int> BlendFunction)<br />The func would get the source and the destination color as input and should return the new destination color as int.<br /><br />But, the main goal of the library is performance and calling a func for each pixel would have a certain impact on it. And, do you really need 20 blend modes?Rene Schultehttps://www.blogger.com/profile/12777157871967896549noreply@blogger.comtag:blogger.com,1999:blog-563071785757928434.post-58473835569616914392010-01-29T12:23:39.014+01:002010-01-29T12:23:39.014+01:00Great work! When I saw the blendmodes I was immedi...Great work! When I saw the blendmodes I was immediatly hooked. One thing I'd like to know is if you have any ideas how to make it more pluggable when I want to add more blendmodes. If i want to add 20 blendmodes then the code becomes a bit silly.Anonymoushttps://www.blogger.com/profile/17276888582260272949noreply@blogger.com