Beispiel #1
0
 /// <summary>
 /// Creates an operator logo.
 /// </summary>
 /// <param name="otaBitmap">The OTA bitmap to use as the logo. Maximum size is 72x14 pixels.</param>
 /// <param name="mobileCountryCode">MCC. The operator's country code. Must be 3 digits long.</param>
 /// <param name="mobileNetworkCode">MNC. The operator's network code. Must be 2 digits long.</param>
 /// <returns>A byte array containing the generated operator logo.</returns>
 /// <exception cref="T:System.ArgumentNullException">otaBitmap is null.</exception>
 /// <exception cref="T:System.ArgumentException"><para>mobileCountryCode is not 3 digits long.</para><para> -or- </para>
 /// <para>mobileNetworkCode is not 2 digits long.</para>
 /// <para> -or- </para><para>The bitmap is larger than 72x14 pixels.</para>
 /// </exception>
 public static byte[] CreateOperatorLogo(OtaBitmap otaBitmap, string mobileCountryCode, string mobileNetworkCode)
 {
     if (otaBitmap != null)
     {
         if (otaBitmap.Width > 72 || otaBitmap.Height > 14)
         {
             string[] str = new string[5];
             str[0] = "Bitmaps used as operator logos must not be larger than ";
             int num = 72;
             str[1] = num.ToString();
             str[2] = "x";
             int num1 = 14;
             str[3] = num1.ToString();
             str[4] = " pixels.";
             throw new ArgumentException(string.Concat(str));
         }
         else
         {
             if (mobileCountryCode.Length == 3)
             {
                 if (mobileNetworkCode.Length == 2)
                 {
                     byte   num2      = 48;
                     byte[] numArray  = Calc.HexToInt(BcdWorker.EncodeSemiOctets(mobileCountryCode.PadRight(4, 'F')));
                     byte[] numArray1 = Calc.HexToInt(BcdWorker.EncodeSemiOctets(mobileNetworkCode.PadRight(2, 'F')));
                     int    length    = 1 + (int)numArray.Length + (int)numArray1.Length + 1;
                     int    length1   = 0;
                     byte[] numArray2 = new byte[length];
                     int    num3      = length1;
                     length1         = num3 + 1;
                     numArray2[num3] = num2;
                     numArray.CopyTo(numArray2, length1);
                     length1 = length1 + (int)numArray.Length;
                     numArray1.CopyTo(numArray2, length1);
                     length1 = length1 + (int)numArray1.Length;
                     int num4 = length1;
                     length1         = num4 + 1;
                     numArray2[num4] = 10;
                     byte[] byteArray = otaBitmap.ToByteArray();
                     byte[] numArray3 = new byte[(int)numArray2.Length + (int)byteArray.Length];
                     numArray2.CopyTo(numArray3, 0);
                     byteArray.CopyTo(numArray3, length1);
                     return(numArray3);
                 }
                 else
                 {
                     throw new ArgumentException("mobileNetworkCode must be 2 digits long.", "mobileNetworkCode");
                 }
             }
             else
             {
                 throw new ArgumentException("mobileCountryCode must be 3 digits long.", "mobileCountryCode");
             }
         }
     }
     else
     {
         throw new ArgumentNullException("otaBitmap");
     }
 }
Beispiel #2
0
 /// <summary>
 /// Creates a new OTA bitmap from an existing <see cref="T:System.Drawing.Bitmap" /> object.
 /// </summary>
 /// <param name="bitmap">The <see cref="T:System.Drawing.Bitmap" /> to create the OTA bitmap from.</param>
 public OtaBitmap(Bitmap bitmap)
     : this(OtaBitmap.BitmapToOtaBitmap(bitmap))
 {
 }
Beispiel #3
0
 /// <summary>
 /// Returns the <see cref="T:System.Drawing.Bitmap" /> equivalent of this instance.
 /// </summary>
 /// <returns>The <see cref="T:System.Drawing.Bitmap" />.</returns>
 public Bitmap ToBitmap()
 {
     return(OtaBitmap.OtaBitmapToBitmap(this.bitmap));
 }
 /// <summary>
 /// Creates an operator logo.
 /// </summary>
 /// <param name="otaBitmap">The OTA bitmap to use as the logo. Maximum size is 72x14 pixels.</param>
 /// <param name="mobileCountryCode">MCC. The operator's country code. Must be 3 digits long.</param>
 /// <param name="mobileNetworkCode">MNC. The operator's network code. Must be 2 digits long.</param>
 /// <returns>A byte array containing the generated operator logo.</returns>
 /// <exception cref="T:System.ArgumentNullException">otaBitmap is null.</exception>
 /// <exception cref="T:System.ArgumentException"><para>mobileCountryCode is not 3 digits long.</para><para> -or- </para>
 /// <para>mobileNetworkCode is not 2 digits long.</para>
 /// <para> -or- </para><para>The bitmap is larger than 72x14 pixels.</para>
 /// </exception>
 public static byte[] CreateOperatorLogo(OtaBitmap otaBitmap, string mobileCountryCode, string mobileNetworkCode)
 {
     if (otaBitmap != null)
     {
         if (otaBitmap.Width > 72 || otaBitmap.Height > 14)
         {
             string[] str = new string[5];
             str[0] = "Bitmaps used as operator logos must not be larger than ";
             int num = 72;
             str[1] = num.ToString();
             str[2] = "x";
             int num1 = 14;
             str[3] = num1.ToString();
             str[4] = " pixels.";
             throw new ArgumentException(string.Concat(str));
         }
         else
         {
             if (mobileCountryCode.Length == 3)
             {
                 if (mobileNetworkCode.Length == 2)
                 {
                     byte num2 = 48;
                     byte[] numArray = Calc.HexToInt(BcdWorker.EncodeSemiOctets(mobileCountryCode.PadRight(4, 'F')));
                     byte[] numArray1 = Calc.HexToInt(BcdWorker.EncodeSemiOctets(mobileNetworkCode.PadRight(2, 'F')));
                     int length = 1 + (int)numArray.Length + (int)numArray1.Length + 1;
                     int length1 = 0;
                     byte[] numArray2 = new byte[length];
                     int num3 = length1;
                     length1 = num3 + 1;
                     numArray2[num3] = num2;
                     numArray.CopyTo(numArray2, length1);
                     length1 = length1 + (int)numArray.Length;
                     numArray1.CopyTo(numArray2, length1);
                     length1 = length1 + (int)numArray1.Length;
                     int num4 = length1;
                     length1 = num4 + 1;
                     numArray2[num4] = 10;
                     byte[] byteArray = otaBitmap.ToByteArray();
                     byte[] numArray3 = new byte[(int)numArray2.Length + (int)byteArray.Length];
                     numArray2.CopyTo(numArray3, 0);
                     byteArray.CopyTo(numArray3, length1);
                     return numArray3;
                 }
                 else
                 {
                     throw new ArgumentException("mobileNetworkCode must be 2 digits long.", "mobileNetworkCode");
                 }
             }
             else
             {
                 throw new ArgumentException("mobileCountryCode must be 3 digits long.", "mobileCountryCode");
             }
         }
     }
     else
     {
         throw new ArgumentNullException("otaBitmap");
     }
 }