Sugrue
Sugrue

Reputation: 3739

How to decompress jpeg bytes in Dot Net Core?

I'm looking at porting some code to dot net core so I can run it on Linux. One part of the code needs to decompress a jpeg file and read the pixel values.

It seems that neither System.Drawing.Bitmap nor System.Windows.Media is available in Dot Net Core.

Is there an alternative?

Upvotes: 0

Views: 407

Answers (1)

Vitaliy Fedorchenko
Vitaliy Fedorchenko

Reputation: 9235

You need to use 3rd party library for this purpose; take a look to the ImageProcessorCore (it can be installed from myget: https://www.myget.org/gallery/imageprocessor ):

using (FileStream stream = File.OpenRead("foo.jpg")) {
  Image image = new Image(stream);
  using (PixelAccessor<Color, uint> pixels = image.Lock()) {
    var pixelColor = pixels[0,0];
  }
}

Upvotes: 2

Related Questions