Vector<int> throws error

This page summarizes the projects mentioned and recommended in the original post on /r/csharp

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • .NET Runtime

    .NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.

  • There is a bug noted in github related to this issue.

  • ImageSharp

    :camera: A modern, cross-platform, 2D Graphics library for .NET

  • You're using the wrong type then. Vector has a variable fixed length that depends on your specific hardware on your machine (ie. on what kind of vectorized registers are available). Assuming SSE2 as a baseline, Vector will always have (at least) a size of 4. On some machines it will have a size of 8, etc. You can't use it to store an arbitrarily long sequence of values, and even if you could, what you're doing here is very inefficient. If you want to store eg. a pixel color in BGRA32 format, storing each channel as an int means you'd be wasting 4x times the memory you need. You should instead store each channel as a byte, and have your pixel type only have a size of exactly 32 bits. For reference, I'd suggest taking a look at the Bgra32 pixel type in ImageSharp: https://github.com/SixLabors/ImageSharp/blob/master/src/ImageSharp/PixelFormats/PixelImplementations/Bgra32.cs.

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts