Ejemplo n.º 1
0
        internal void RequestMeta(string filename)
        {
            taskThread.QueueThisUpPlease(() =>
            {
                var filenameMeta = fileMapping.AddGetMetaFilename(filename);
                fileMapping.MakeSureDataFolderExists(filenameMeta);

                if (!File.Exists(filenameMeta))
                {
                    // generates the thumbnails
                    UiConsolePush(VidkaConsoleLogLevel.Info, "generating meta " + Path.GetFileName(filenameMeta));
                    var op1 = new MetadataExtraction(filename, filenameMeta);
                    UiPushResult(op1);
                    if (MetaReady != null && op1.MetaXml != null)
                    {
                        MetaReady(filename, op1.MetaXml);
                    }
                }
                else
                {
                    var metaXml = MetadataExtraction.LoadMetaFromXml(filenameMeta);
                    if (MetaReady != null)
                    {
                        MetaReady(filename, metaXml);
                    }
                }
            });
        }
Ejemplo n.º 2
0
 public void ___paintEnd()
 {
     // remove images we are no longer using
     cxzxc("___paintEnd");
     cxzxc("to-remove:" + imgNotUsed.Select(x => debug_urlIndex(x)).StringJoin(","));
     foreach (var notUsed in imgNotUsed)
     {
         cxzxc("removing " + debug_url_thumb(notUsed));
         //if (!thumbsCache.ContainsKey(notUsed))
         //	continue;
         var img = imgCache[notUsed];
         imgCache.Remove(notUsed);
         img.Dispose();
     }
     imgNotUsed.Clear();
     cxzxc("to-add:" + requests_thumb.SelectMany(x => x.Value.Select(y => "" + y)).StringJoin(","));
     // start loading any new images which we require
     foreach (var filename in requests_thumb.Keys)
     {
         var indices = requests_thumb[filename];
         taskThread.QueueThisUpPlease(() =>
         {
             if (!File.Exists(filename))
             {
                 return;
             }
             Bitmap thumbsAll = System.Drawing.Image.FromFile(filename, true) as Bitmap;
             var nRow         = thumbsAll.Width / ThumbnailTest.ThumbW;
             var nCol         = thumbsAll.Height / ThumbnailTest.ThumbH;
             foreach (var index in indices)
             {
                 var url = getUrl_thumb(filename, index);
                 if (imgCache.ContainsKey(url))
                 {
                     continue;
                 }
                 Bitmap target   = new Bitmap(ThumbnailTest.ThumbW, ThumbnailTest.ThumbH);
                 rectCrop.X      = ThumbnailTest.ThumbW * (index % nCol);
                 rectCrop.Y      = ThumbnailTest.ThumbH * (index / nRow);
                 rectCrop.Width  = ThumbnailTest.ThumbW;
                 rectCrop.Height = ThumbnailTest.ThumbH;
                 using (Graphics g = Graphics.FromImage(target))
                     g.DrawImage(thumbsAll, rectThumb, rectCrop, GraphicsUnit.Pixel);
                 cxzxc("adding " + debug_url_thumb(url));
                 imgCache.Add(url, target);
                 if (imgCache.Count > MAX_ThumbsBeforeCleanseUnused)
                 {
                     removeUnusedOnNextRepaint = true;
                 }
                 // remove from requests
                 //requests[filename].Remove(index);
                 //if (requests[filename].Count == 0)
                 //	requests.Remove(filename);
             }
         });
     }
     requests_thumb.Clear();
     foreach (var filename in requests_other.Keys)
     {
         var url = filename;
         taskThread.QueueThisUpPlease(() =>
         {
             if (imgCache.ContainsKey(url))
             {
                 return;
             }
             if (!File.Exists(filename))
             {
                 return;
             }
             Bitmap bmp = System.Drawing.Image.FromFile(filename, true) as Bitmap;
             cxzxc("adding " + debug_url_other(url));
             imgCache.Add(url, bmp);
             if (imgCache.Count > MAX_ThumbsBeforeCleanseUnused)
             {
                 removeUnusedOnNextRepaint = true;
             }
         });
     }
     requests_other.Clear();
 }