Beispiel #1
0
 public byte[] GetBitmap24Data(Stream stream, out int width)
 {
     width = 0;
     if (Extension == "PCX")
     {
         byte[] array;
         if (newVal == null)
         {
             byte[] bts = new byte[Size];
             stream.Position = Offset;
             stream.Read(bts, 0, Size);
             array = ZlibWrapper.UnZlib(bts);
         }
         else
         {
             array = newVal;
         }
         var file = new PcxFile(array);
         try
         {
             return(file.GetBitmap24Bytes(out width));
         }
         catch
         {
             return(null);
         }
     }
     return(null);
 }
Beispiel #2
0
 public DefFile GetDefFile(Stream stream)
 {
     if (newVal == null)
     {
         stream.Position = Offset;
         if (Size != 0)
         {
             var bts = new byte[Size];
             stream.Read(bts, 0, Size);
             newVal = ZlibWrapper.UnZlib(bts);
         }
         else
         {
             newVal = new byte[RealSize];
             stream.Read(newVal, 0, RealSize);
         }
     }
     return(new DefFile(this, newVal));
 }
Beispiel #3
0
        public Bitmap GetBitmap(Stream stream)
        {
            if (Extension == "PCX")
            {
                byte[] array;
                if (newVal == null)
                {
                    if (Size != 0)
                    {
                        byte[] bts = new byte[Size];
                        stream.Position = Offset;
                        stream.Read(bts, 0, Size);
                        array = ZlibWrapper.UnZlib(bts);
                    }
                    else if (RealSize != 0)
                    {
                        array           = new byte[RealSize];
                        stream.Position = Offset;
                        stream.Read(array, 0, RealSize);
                    }
                    else
                    {
                        throw new Exception("Image size unknown");
                    }
                }
                else
                {
                    array = newVal;
                }

                var file = new PcxFile(array);
                try
                {
                    return(file.GetBitmap());
                }
                catch (Exception ex)
                {
                    return(null);
                }
            }
            return(null);
        }
Beispiel #4
0
        public byte[] GetRawData(Stream stream)
        {
            if (HasChanged && !Created)
            {
                return(newVal);
            }


            if (Size != 0)
            {
                byte[] bts = new byte[Size];
                stream.Position = Offset;
                stream.Read(bts, 0, Size);
                return(ZlibWrapper.UnZlib(bts));
            }
            else
            {
                byte[] bts = new byte[RealSize];
                stream.Position = Offset;
                stream.Read(bts, 0, RealSize);
                return(bts);
            }
        }