简体   繁体   中英

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?

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];
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM