novembre 2023 Blog Posts

Water in Wine with C#

A common need when working with images is to convert arrays containing pixels from a type to another. For example an uint[] to byte[] conversion is common, but very slow and memory intensive. Here the fastest method I developed for real-time applications: The code is unsafe (additional testing recommended) and may not work with future CLR Runtimes, but it's pretty readable and fast. In few words the code is changing the type of the array by overwriting the CLR Method Table and then resizing the array in a similiar way. A new array (of the desired type) pointing to the original one is then...

posted @ venerdì 24 novembre 2023 21:51 | Feedback (2)