Пример #1
0
 public static BooruImage FromURL(string URL)
 {
     if (Helper.CheckURL(URL))
     {
         try
         {
             using (WebClient client = new WebClient())
                 return(BooruImage.FromBytes(client.DownloadData(URL)));
         }
         catch { }
     }
     return(null);
 }
Пример #2
0
        /*
         * public void ToWriter(BinaryWriter Writer, Action<float> ProgressCallback)
         * {
         *  Writer.Write(Bytes.Length);
         *  if (ProgressCallback != null)
         *  {
         *      int chunkSize = 1024 * 5;
         *      int chunkCount = Bytes.Length / chunkSize;
         *      for (int i = 0; i < chunkCount; i++)
         *      {
         *          Writer.Write(Bytes, i * chunkSize, chunkSize);
         *          ProgressCallback(i * (float)chunkSize / Bytes.Length);
         *      }
         *      Writer.Write(Bytes, chunkCount * chunkSize, Bytes.Length % chunkSize);
         *      ProgressCallback(1f);
         *  }
         *  else Writer.Write(Bytes);
         * }
         */

        public static BooruImage FromReader(ReaderWriter Reader)
        {
            return(BooruImage.FromBytes(Reader.ReadBytes()));
        }