private static DecodeDelegate GetDecodeDelegate(PsdColorMode psdColorMode) { switch (psdColorMode) { case PsdColorMode.Bitmap: return(SetPDNRowBitmap); case PsdColorMode.Grayscale: case PsdColorMode.Duotone: return(SetPDNRowGrayscale); case PsdColorMode.Indexed: return(SetPDNRowIndexed); case PsdColorMode.RGB: return(SetPDNRowRgb); case PsdColorMode.CMYK: return(SetPDNRowCmyk); case PsdColorMode.Lab: return(SetPDNRowLab); case PsdColorMode.Multichannel: throw new Exception("Cannot decode multichannel."); default: throw new Exception("Unknown color mode."); } }
/////////////////////////////////////////////////////////////////////////// private void LoadHeader(PsdBinaryReader reader) { Debug.WriteLine("LoadHeader started at " + reader.BaseStream.Position.ToString(CultureInfo.InvariantCulture)); var signature = reader.ReadAsciiChars(4); if (signature != "8BPS") { throw new PsdInvalidException("The given stream is not a valid PSD file"); } Version = reader.ReadInt16(); if (Version != 1) { throw new PsdInvalidException("The PSD file has an unknown version"); } //6 bytes reserved reader.BaseStream.Position += 6; this.ChannelCount = reader.ReadInt16(); this.RowCount = reader.ReadInt32(); this.ColumnCount = reader.ReadInt32(); BitDepth = reader.ReadInt16(); ColorMode = (PsdColorMode)reader.ReadInt16(); }
/////////////////////////////////////////////////////////////////////////// private void LoadHeader(PsdBinaryReader reader) { Util.DebugMessage(reader.BaseStream, "Load, Begin, File header"); var signature = reader.ReadAsciiChars(4); if (signature != "8BPS") { throw new PsdInvalidException("The given stream is not a valid PSD file"); } Version = (PsdFileVersion)reader.ReadInt16(); Util.DebugMessage(reader.BaseStream, "Load, Info, Version {0}", (int)Version); if ((Version != PsdFileVersion.Psd) && (Version != PsdFileVersion.PsbLargeDocument)) { throw new PsdInvalidException("The PSD file has an unknown version"); } //6 bytes reserved reader.BaseStream.Position += 6; this.ChannelCount = reader.ReadInt16(); this.RowCount = reader.ReadInt32(); this.ColumnCount = reader.ReadInt32(); BitDepth = reader.ReadInt16(); ColorMode = (PsdColorMode)reader.ReadInt16(); Util.DebugMessage(reader.BaseStream, "Load, End, File header"); }
private static DecodeDelegate GetDecodeDelegate32(PsdColorMode psdColorMode) { switch (psdColorMode) { case PsdColorMode.Grayscale: return(SetPDNRowGrayscale32); case PsdColorMode.RGB: return(SetPDNRowRgb32); default: throw new PsdInvalidException( "32-bit HDR images must be either RGB or grayscale."); } }
public static Int16 MinChannelCount(this PsdColorMode colorMode) { switch (colorMode) { case PsdColorMode.Bitmap: case PsdColorMode.Duotone: case PsdColorMode.Grayscale: case PsdColorMode.Indexed: case PsdColorMode.Multichannel: return(1); case PsdColorMode.Lab: case PsdColorMode.Rgb: return(3); case PsdColorMode.Cmyk: return(4); } throw new ArgumentException("Unknown color mode."); }
/////////////////////////////////////////////////////////////////////////// private void LoadHeader(PsdBinaryReader reader) { var signature = reader.ReadAsciiChars(4); if (signature != "8BPS") throw new PsdInvalidException("The given stream is not a valid PSD file"); Version = reader.ReadInt16(); if (Version != 1) throw new PsdInvalidException("The PSD file has an unknown version"); //6 bytes reserved reader.BaseStream.Position += 6; this.ChannelCount = reader.ReadInt16(); this.RowCount = reader.ReadInt32(); this.ColumnCount = reader.ReadInt32(); BitDepth = reader.ReadInt16(); ColorMode = (PsdColorMode)reader.ReadInt16(); }