Guest User

Untitled

a guest
Jul 28th, 2021
18
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. switch (Path.GetExtension(path).ToLowerInvariant())
  2. {
  3.     case ".lip":
  4.         try
  5.         {
  6.             SQLiteConnection sqlite = new SQLiteConnection("Data Source=" + path + ";Read Only=True");
  7.             sqlite.Open();
  8.             SQLiteCommand command = sqlite.CreateCommand();
  9.             command.CommandText = "SELECT ImageData FROM CanvasPreview ORDER BY ImageWidth * ImageHeight DESC";
  10.             using (SQLiteDataReader sqliteReader = command.ExecuteReader())
  11.                 if (sqliteReader.Read())
  12.                     using (MemoryStream mem = new MemoryStream(sqliteReader.GetBytes()))
  13.                         image = Image.FromStream(mem);
  14.             sqlite.Close();
  15.         }
  16.         catch { }
  17.         break;
  18.     case ".clip":
  19.     {
  20.         byte[] sqliteData;
  21.         using (FileStream stream = File.OpenRead(path))
  22.         {
  23.             using (BinaryReader reader = new BinaryReader(stream))
  24.             {
  25.                 stream.Seek(0x30, SeekOrigin.Begin);
  26.                 long sqliteOffset = reader.ReadInt64BE();
  27.                 sqliteOffset += 0x10;
  28.                 stream.Seek(sqliteOffset, SeekOrigin.Begin);
  29.                 sqliteData = new byte[stream.Length - stream.Position];
  30.                 stream.Read(sqliteData, 0, sqliteData.Length);
  31.             }
  32.         }
  33.  
  34.         string temp = Path.GetTempFileName();
  35.         try
  36.         {
  37.             File.WriteAllBytes(temp, sqliteData);
  38.             using (SQLiteConnection sqlite = new SQLiteConnection("Data Source=" + temp))
  39.             {
  40.                 sqlite.Open();
  41.                 using (SQLiteCommand command = sqlite.CreateCommand())
  42.                 {
  43.                     command.CommandText = "SELECT ImageData FROM CanvasPreview ORDER BY ImageWidth * ImageHeight DESC";
  44.                     using (SQLiteDataReader sqliteReader = command.ExecuteReader())
  45.                         if (sqliteReader.Read())
  46.                             using (MemoryStream mem = new MemoryStream(sqliteReader.GetBytes()))
  47.                                 image = Image.FromStream(mem);
  48.                 }
  49.                 sqlite.Close();
  50.             }
  51.         }
  52.         finally
  53.         {
  54.             SQLiteConnection.ClearAllPools();
  55.             GC.Collect();
  56.             GC.WaitForPendingFinalizers();
  57.             if (File.Exists(temp))
  58.                 File.Delete(temp);
  59.         }
  60.         break;
  61.     }
  62.     default:
  63.         using (FileStream file = new FileStream(path, FileMode.Open, FileAccess.Read))
  64.             image = Image.FromStream(file);
  65.         break;
  66. }
  67.  
RAW Paste Data