Browse Source

Rename pixelData

af/merge-core
James Jackson-South 10 years ago
parent
commit
3e7119c775
  1. 43
      src/ImageSharp/Formats/Png/PngEncoderCore.cs

43
src/ImageSharp/Formats/Png/PngEncoderCore.cs

@ -36,9 +36,9 @@ namespace ImageSharp.Formats
/// <summary> /// <summary>
/// Contains the raw pixel data from the image. /// Contains the raw pixel data from an indexed image.
/// </summary> /// </summary>
private byte[] pixelData; private byte[] palettePixelData;
/// <summary> /// <summary>
/// The image width. /// The image width.
@ -118,20 +118,16 @@ namespace ImageSharp.Formats
this.height = image.Height; this.height = image.Height;
// Write the png header. // Write the png header.
stream.Write( this.chunkDataBuffer[0] = 0x89; // Set the high bit.
new byte[] this.chunkDataBuffer[1] = 0x50; // P
{ this.chunkDataBuffer[2] = 0x4E; // N
0x89, // Set the high bit. this.chunkDataBuffer[3] = 0x47; // G
0x50, // P this.chunkDataBuffer[4] = 0x0D; // Line ending CRLF
0x4E, // N this.chunkDataBuffer[5] = 0x0A; // Line ending CRLF
0x47, // G this.chunkDataBuffer[6] = 0x1A; // EOF
0x0D, // Line ending CRLF this.chunkDataBuffer[7] = 0x0A; // LF
0x0A, // Line ending CRLF
0x1A, // EOF stream.Write(this.chunkDataBuffer, 0, 8);
0x0A // LF
},
0,
8);
// Ensure that quality can be set but has a fallback. // Ensure that quality can be set but has a fallback.
int quality = this.Quality > 0 ? this.Quality : image.Quality; int quality = this.Quality > 0 ? this.Quality : image.Quality;
@ -179,14 +175,6 @@ namespace ImageSharp.Formats
{ {
this.CollectIndexedBytes(image, stream, header); this.CollectIndexedBytes(image, stream, header);
} }
else if (this.PngColorType == PngColorType.Grayscale || this.PngColorType == PngColorType.GrayscaleWithAlpha)
{
//this.CollectGrayscaleBytes(image);
}
else
{
// this.CollectColorBytes(image);
}
this.WritePhysicalChunk(stream, image); this.WritePhysicalChunk(stream, image);
this.WriteGammaChunk(stream); this.WriteGammaChunk(stream);
@ -247,9 +235,10 @@ namespace ImageSharp.Formats
where TColor : struct, IPackedPixel<TPacked> where TColor : struct, IPackedPixel<TPacked>
where TPacked : struct where TPacked : struct
{ {
// Quatize the image and get the pixels // Quatize the image and get the pixels.
// TODO: It might be an idea to add a pixel accessor to QuantizedImage to allow us to work by row.
QuantizedImage<TColor, TPacked> quantized = this.WritePaletteChunk(stream, header, image); QuantizedImage<TColor, TPacked> quantized = this.WritePaletteChunk(stream, header, image);
this.pixelData = quantized.Pixels; this.palettePixelData = quantized.Pixels;
} }
/// <summary> /// <summary>
@ -332,7 +321,7 @@ namespace ImageSharp.Formats
switch (this.PngColorType) switch (this.PngColorType)
{ {
case PngColorType.Palette: case PngColorType.Palette:
Buffer.BlockCopy(this.pixelData, row * bytesPerScanline, rawScanline, 0, bytesPerScanline); Buffer.BlockCopy(this.palettePixelData, row * bytesPerScanline, rawScanline, 0, bytesPerScanline);
break; break;
case PngColorType.Grayscale: case PngColorType.Grayscale:
case PngColorType.GrayscaleWithAlpha: case PngColorType.GrayscaleWithAlpha:

Loading…
Cancel
Save