Which WPF Brush to use and how to create it
I have a WPF 3D application (C# .NET 4.0) that has a lot of 3D geometries. Now I need to color these geometries by applying a texture. The source for the texture is one large .PNG file like the following:
The .PNG file contains repeating sections. One section for each combination of Case, Deviation and Harmonic. Cases have one or more deviations (nDev). Cases also have one or more harmonics (nHarm). So the number of sections is equal to the sum of the nDev * nHarm of each Case.
Each row of pixels within a section maps to exactly one geometry.
The end-user should be able to select a Case (trough combobox), Deviation (trough slider) and Harmonic (trough slider). This combination leads to a section offset. The basic idea is that this section offset can be used to reposition the "mapping a开发者_JAVA百科rea" over the orignal .png, using a TranslateTransform.
Now the challenge(s) I'm facing. A normal resultsfile contains about: 200 to 400 rows per section 32 to 64 harmonics up till 250 deviations 20 till 30 cases
In order to get maximum performance, I should use textures that stay within the RenderCapability.MaxHardwareTextureSize
bounds. So I want to split up the .png per Case (and if necessary per deviation and/or harmonic).
Question: How can I split up the original .png file in multiple brushes? And which brush to use for maximum performance? Should I stick with ImageBrush (since it's static after initial splitting up) or use a BitmapCacheBrush i.e.?
You might want to consider using WriteableBitmap instead of a WPF Brush. You can then write any pixels you want without caching anything but the pixel data.
精彩评论