xyzzer / WinRTXamlToolkit

WinRT XAML Toolkit
Other
282 stars 67 forks source link

Change Image Pixel Color #38

Open kinju4374 opened 8 years ago

kinju4374 commented 8 years ago

Hi,

Can you please suggest does this API has any Image Extensions that will me to change Image pixel color and it will not affect performance of my app?

If yes, please let me know which one to use and if you have any sample it would be a great help.

Thanks

xyzzer commented 8 years ago

Every instruction affects performance in some way, so it all depends on what you're trying to achieve and how much you're willing to invest in the code.

Accessing pixels of a WriteableBitmap isn't too expensive unless you would like to redraw them many times per second. Possibly using C++ would be faster than in C#. Using Direct2D, perhaps with Win2D or SharpDX wrappers should let you achieve 60FPS easily. Check my code here for a sample: https://github.com/xyzzer/Win2DChartSample If you'd like to calculate the color of each pixel of a frame many times per second - you might want to look into lower level Direct3D/DXGI texture manipulation. I think you might be able to map a CPU texture if you'd like to use your CPU to set pixel colors or better yet - use a pixel shader to render the texture fully on the GPU (if available). If you really only want to set a color of one pixel - you could just have 1x1 XAML Grid element of a specific color laid out at a specific position on the screen.

kinju4374 commented 8 years ago

Thanks will give it a try.

Actually, I am using some icons which I download from the server. So, what I want to do is download the icon, change it pixel color and then store the new colored image in the local storage of app.

I tried WriteableBitmapEx API but it is taking more than 3 minutes for 10-15 icons. I have attached my CS file. ChangeImageColor.zip