Example #1
0
        public PsdReader(IBinaryStream input, PsdMetaData info)
        {
            m_info  = info;
            m_input = input;
            int bpc = m_info.BPP / m_info.Channels;

            switch (m_info.Mode)
            {
            case 3:
                if (8 != bpc)
                {
                    throw new NotSupportedException();
                }
                if (3 == m_info.Channels)
                {
                    Format = PixelFormats.Bgr24;
                }
                else if (4 == m_info.Channels)
                {
                    Format = PixelFormats.Bgra32;
                }
                else if (m_info.Channels > 4)
                {
                    Format = PixelFormats.Bgr32;
                }
                else
                {
                    throw new NotSupportedException();
                }
                break;

//            case 2: Format = PixelFormats.Indexed8; break;
            case 1:
                if (8 == bpc)
                {
                    Format = PixelFormats.Gray8;
                }
                else if (16 == bpc)
                {
                    Format = PixelFormats.Gray16;
                }
                else
                {
                    throw new NotSupportedException();
                }
                break;

            case 0: Format = PixelFormats.BlackWhite; break;

            default:
                throw new NotImplementedException("Not supported PSD color mode");
            }
            m_channel_size = (int)m_info.Height * (int)m_info.Width * bpc / 8;
        }
Example #2
0
 public PsdReader(Stream input, PsdMetaData info)
 {
     m_info = info;
     m_input = new BinaryReader (input, Encoding.Unicode, true);
     int bpc = m_info.BPP / m_info.Channels;
     switch (m_info.Mode)
     {
     case 3:
         if (8 != bpc)
             throw new NotSupportedException();
         if (3 == m_info.Channels)
             Format = PixelFormats.Bgr24;
         else if (4 == m_info.Channels)
             Format = PixelFormats.Bgra32;
         else
             throw new NotSupportedException();
         break;
     //            case 2: Format = PixelFormats.Indexed8; break;
     case 1:
         if (8 == bpc)
             Format = PixelFormats.Gray8;
         else if (16 == bpc)
             Format = PixelFormats.Gray16;
         else
             throw new NotSupportedException();
         break;
     case 0: Format = PixelFormats.BlackWhite; break;
     default:
         throw new NotImplementedException ("Not supported PSD color mode");
     }
     m_channel_size = (int)m_info.Height * (int)m_info.Width * bpc / 8;
 }