swharden / Spectrogram

.NET library for creating spectrograms (visual representations of frequency spectrum over time)
https://nuget.org/packages/Spectrogram
MIT License
319 stars 57 forks source link

SpectrogramGenerator private members to protected #57

Closed jmcmeen closed 3 weeks ago

jmcmeen commented 1 year ago

I am extending/inheriting SpectrogramGenerator to implement a method called GetBytes that returns the spectrogram image data as an array of bytes. The method is modelled after SaveImage, where I am instead of saving the Bitmap to file, I am saving to a MemoryStream and returning the stream as a byte array. I am trying to minimize writing to disk in operations where I am calling SaveImage millions of times and I don't need the .png (or other formats), just it's bytes.

SaveImage requires the private FFTs property. So in my new GetBytes method, I can't access that property. If it were protected, along with some other methods and fields, I believe this would make the class more extensible.

jmcmeen commented 1 year ago

Or add an implementation of a method GetImageBytes that mirrors SaveImage, allowing me to pass in the extension instead of the file name. Creates a memory stream and returns the memory stream as an array of bytes.