コード例 #1
0
        /// <summary>
        /// Gets a PNG image's width from base 64 encoded data.
        /// </summary>
        /// <param name="data">The data.</param>
        /// <returns>The width.</returns>
        public static int GetPngWidthFromBase64Data(string data)
        {
            // Preconditions
            if (data == null || data.Length < 32)
            {
                return(0);
            }

            // Implementation
            byte[] bytes      = Convert.FromBase64String(data.Substring(0, 32));
            byte[] widthBytes = PngHelper.Slice(bytes, 16, 20);
            Array.Reverse(widthBytes);
            int width = BitConverter.ToInt32(widthBytes, 0);

            return(width);
        }
コード例 #2
0
        /// <summary>
        /// Gets a PNG image's height from base 64 encoded data.
        /// </summary>
        /// <param name="data">The data.</param>
        /// <returns>The height.</returns>
        public static int GetPngHeightFromBase64Data(string data)
        {
            // Preconditions
            if (data == null || data.Length < 32)
            {
                return(0);
            }

            // Implementation
            byte[] bytes       = Convert.FromBase64String(data.Substring(0, 32));
            byte[] heightBytes = PngHelper.Slice(bytes, 20, 24);
            Array.Reverse(heightBytes);
            int height = BitConverter.ToInt32(heightBytes, 0);

            return(height);
        }