private static int GetRepeatCount(BitmapDecoder decoder) { BitmapMetadata applicationExtension = ImageBehavior.GetApplicationExtension(decoder, "NETSCAPE2.0"); if (applicationExtension != null) { byte[] queryOrNull = applicationExtension.GetQueryOrNull <byte[]>("/Data"); if (queryOrNull != null && queryOrNull.Length >= 4) { return((int)BitConverter.ToUInt16(queryOrNull, 2)); } } return(1); }