Browse Source

Fix file encoding

Former-commit-id: 94200cfe9279e3d20b99a9d9fa1a564547cdb801
Former-commit-id: 157766beec509e0122c5eceb61d564fda693e0ec
Former-commit-id: 10b1c0e30d28d822905fa00e4127c07c9ad6ee04
af/merge-core
James Jackson-South 10 years ago
parent
commit
8189e86733
  1. 2
      src/ImageProcessorCore/Formats/Jpg/Block.cs
  2. 2
      src/ImageProcessorCore/Formats/Jpg/FDCT.cs
  3. 2
      src/ImageProcessorCore/Formats/Jpg/IDCT.cs
  4. 26
      src/ImageProcessorCore/Formats/Jpg/JpegDecoder.cs
  5. 2
      src/ImageProcessorCore/Formats/Jpg/JpegEncoderCore.cs

2
src/ImageProcessorCore/Formats/Jpg/Block.cs

@ -1,4 +1,4 @@
namespace ImageProcessorCore.Formats namespace ImageProcessorCore.Formats
{ {
internal class Block internal class Block
{ {

2
src/ImageProcessorCore/Formats/Jpg/FDCT.cs

@ -1,4 +1,4 @@
// <copyright file="FDCT.cs" company="James Jackson-South"> // <copyright file="FDCT.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors. // Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright> // </copyright>

2
src/ImageProcessorCore/Formats/Jpg/IDCT.cs

@ -1,4 +1,4 @@
// <copyright file="IDCT.cs" company="James Jackson-South"> // <copyright file="IDCT.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors. // Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright> // </copyright>

26
src/ImageProcessorCore/Formats/Jpg/JpegDecoder.cs

@ -97,13 +97,15 @@ namespace ImageProcessorCore.Formats
JpegDecoderCore decoder = new JpegDecoderCore(); JpegDecoderCore decoder = new JpegDecoderCore();
decoder.Decode(stream, image, false); decoder.Decode(stream, image, false);
int pixelWidth = decoder.width; // TODO: When nComp is 3 we set the ImageBase pixels internally, Eventually we should
int pixelHeight = decoder.height; // do the same here
float[] pixels = new float[pixelWidth * pixelHeight * 4];
if (decoder.nComp == 1) if (decoder.nComp == 1)
{ {
int pixelWidth = decoder.width;
int pixelHeight = decoder.height;
float[] pixels = new float[pixelWidth * pixelHeight * 4];
Parallel.For( Parallel.For(
0, 0,
pixelHeight, pixelHeight,
@ -123,16 +125,10 @@ namespace ImageProcessorCore.Formats
image.SetPixels(pixelWidth, pixelHeight, pixels); image.SetPixels(pixelWidth, pixelHeight, pixels);
} }
else if (decoder.nComp == 3) else if (decoder.nComp != 3)
{
// pixels = decoder.imgrgb.pixels;
}
else
{ {
throw new NotSupportedException("JpegDecoder only supports RGB and Grayscale color spaces."); throw new NotSupportedException("JpegDecoder only supports RGB and Grayscale color spaces.");
} }
//image.SetPixels(pixelWidth, pixelHeight, pixels);
} }
/// <summary> /// <summary>
@ -161,9 +157,9 @@ namespace ImageProcessorCore.Formats
{ {
bool isExif = bool isExif =
header[6] == 0x45 && // E header[6] == 0x45 && // E
header[7] == 0x78 && // x header[7] == 0x78 && // X
header[8] == 0x69 && // i header[8] == 0x69 && // I
header[9] == 0x66 && // f header[9] == 0x66 && // F
header[10] == 0x00; header[10] == 0x00;
return isExif; return isExif;

2
src/ImageProcessorCore/Formats/Jpg/JpegEncoderCore.cs

@ -1,4 +1,4 @@
namespace ImageProcessorCore.Formats namespace ImageProcessorCore.Formats
{ {
using System; using System;
using System.IO; using System.IO;

Loading…
Cancel
Save