summary refs log tree commit diff
path: root/crypto/src/bcpg/attr/ImageAttrib.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/bcpg/attr/ImageAttrib.cs')
-rw-r--r--crypto/src/bcpg/attr/ImageAttrib.cs70
1 files changed, 37 insertions, 33 deletions
diff --git a/crypto/src/bcpg/attr/ImageAttrib.cs b/crypto/src/bcpg/attr/ImageAttrib.cs
index 73490791c..2d0fef8b8 100644
--- a/crypto/src/bcpg/attr/ImageAttrib.cs
+++ b/crypto/src/bcpg/attr/ImageAttrib.cs
@@ -3,25 +3,29 @@ using System.IO;
 
 namespace Org.BouncyCastle.Bcpg.Attr
 {
-	/// <remarks>Basic type for a image attribute packet.</remarks>
+    /// <remarks>Basic type for a image attribute packet.</remarks>
     public class ImageAttrib
-		: UserAttributeSubpacket
+        : UserAttributeSubpacket
     {
-		public enum Format : byte
-		{
-			Jpeg = 1
-		}
+        public enum Format : byte
+        {
+            Jpeg = 1
+        }
 
-		private static readonly byte[] Zeroes = new byte[12];
+        private static readonly byte[] Zeroes = new byte[12];
 
-		private int     hdrLength;
+        private int     hdrLength;
         private int     _version;
         private int     _encoding;
         private byte[]  imageData;
 
-        public ImageAttrib(
-            byte[] data)
-            : base(UserAttributeSubpacketTag.ImageAttribute, data)
+        public ImageAttrib(byte[] data)
+            : this(false, data)
+        {
+        }
+
+        public ImageAttrib(bool forceLongLength, byte[] data)
+            : base(UserAttributeSubpacketTag.ImageAttribute, forceLongLength, data)
         {
             hdrLength = ((data[1] & 0xff) << 8) | (data[0] & 0xff);
             _version = data[2] & 0xff;
@@ -31,36 +35,36 @@ namespace Org.BouncyCastle.Bcpg.Attr
             Array.Copy(data, hdrLength, imageData, 0, imageData.Length);
         }
 
-		public ImageAttrib(
-			Format	imageType,
-			byte[]	imageData)
-			: this(ToByteArray(imageType, imageData))
-		{
-		}
+        public ImageAttrib(
+            Format	imageType,
+            byte[]	imageData)
+            : this(ToByteArray(imageType, imageData))
+        {
+        }
 
-		private static byte[] ToByteArray(
-			Format	imageType,
-			byte[]	imageData)
-		{
-			MemoryStream bOut = new MemoryStream();
-			bOut.WriteByte(0x10); bOut.WriteByte(0x00); bOut.WriteByte(0x01);
-			bOut.WriteByte((byte) imageType);
-			bOut.Write(Zeroes, 0, Zeroes.Length);
-			bOut.Write(imageData, 0, imageData.Length);
-			return bOut.ToArray();
-		}
+        private static byte[] ToByteArray(
+            Format	imageType,
+            byte[]	imageData)
+        {
+            MemoryStream bOut = new MemoryStream();
+            bOut.WriteByte(0x10); bOut.WriteByte(0x00); bOut.WriteByte(0x01);
+            bOut.WriteByte((byte) imageType);
+            bOut.Write(Zeroes, 0, Zeroes.Length);
+            bOut.Write(imageData, 0, imageData.Length);
+            return bOut.ToArray();
+        }
 
-		public int Version
+        public virtual int Version
         {
-			get { return _version; }
+            get { return _version; }
         }
 
-        public int Encoding
+        public virtual int Encoding
         {
-			get { return _encoding; }
+            get { return _encoding; }
         }
 
-		public byte[] GetImageData()
+        public virtual byte[] GetImageData()
         {
             return imageData;
         }