I am using a method from an external library, with the following prototypes:
void ReadRaster(byte[] vals);
void ReadRaster(float[] vals);
void ReadRaster(int[] vals);
In order to interface with that function, I was thinking on implementing a generic method such as
void OpenImage<PixelType>(int x, int y) {
// Lots of code
(...)
var pixels = new PixelType[x * y];
ReadRaster(pixels);
// More code
(...)
}
However, this won't do because I would have to limit PixelType
to int
, float
or byte
.
How could I do this?