/// <summary>
        ///     Gets the image data for a given user's avatar.
        /// </summary>
        /// <param name="handle"></param>
        /// <returns></returns>
        public byte[] GetData(ImageHandle handle)
        {
            ImageDimensions dimensions = GetDimensions(handle);

            byte[] data = new byte[dimensions.Width * dimensions.Height * 4];
            GetData(handle, data);
            return(data);
        }
        private static void FetchCallbackImpl(IntPtr ptr, Result result, ImageHandle handleResult)
        {
            GCHandle     h        = GCHandle.FromIntPtr(ptr);
            FetchHandler callback = (FetchHandler)h.Target;

            h.Free();
            callback(result, handleResult);
        }
        /// <summary>
        ///     Gets the image data for a given user's avatar.
        /// </summary>
        /// <param name="handle"></param>
        /// <param name="data"></param>
        /// <exception cref="ResultException"></exception>
        public void GetData(ImageHandle handle, byte[] data)
        {
            Result res = Methods.GetData(methodsPtr, handle, data, data.Length);

            if (res != Result.Ok)
            {
                throw new ResultException(res);
            }
        }
        /// <summary>
        ///     Get's the dimensions for the given user's avatar's source image.
        /// </summary>
        /// <param name="handle"></param>
        /// <returns></returns>
        /// <exception cref="ResultException"></exception>
        public ImageDimensions GetDimensions(ImageHandle handle)
        {
            ImageDimensions ret = new ImageDimensions();
            Result          res = Methods.GetDimensions(methodsPtr, handle, ref ret);

            if (res != Result.Ok)
            {
                throw new ResultException(res);
            }
            return(ret);
        }
        /// <summary>
        ///     Prepares an image to later retrieve data about it.
        /// </summary>
        /// <param name="handle"></param>
        /// <param name="refresh"></param>
        /// <param name="callback"></param>
        public void Fetch(ImageHandle handle, bool refresh, FetchHandler callback)
        {
            GCHandle wrapped = GCHandle.Alloc(callback);

            Methods.Fetch(methodsPtr, handle, refresh, GCHandle.ToIntPtr(wrapped), FetchCallbackImpl);
        }
 /// <summary>
 ///     Prepares an image to later retrieve data about it.
 /// </summary>
 /// <param name="handle"></param>
 /// <param name="callback"></param>
 public void Fetch(ImageHandle handle, FetchHandler callback)
 {
     Fetch(handle, false, callback);
 }