home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 1
Development
Improvement Suggestions
Hide Thumbs.jpg
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="toertchn" data-source="post: 221140" data-attributes="member: 63984"><p>The tracker submission is closed - I also found the way to hide the folder.jpg in filesystem not the best.</p><p></p><p>To store folder thums in cache i modified "Core/Util/Thumbs.cs"</p><p></p><p>[code]</p><p>public static readonly string Folders = Config.GetSubFolder(Config.Dir.Thumbs, @"Folders");</p><p></p><p>public static void CreateFolders()</p><p>{</p><p>...</p><p>System.IO.Directory.CreateDirectory(Folders);</p><p>...</p><p>}</p><p>[/code]</p><p></p><p>In the file "Core/Util/Util.cs" I modified 2 functions:</p><p></p><p>[code]</p><p> public static void SetThumbnails(ref GUIListItem item)</p><p> {</p><p> if (item == null) return;</p><p> string strThumb = string.Empty;</p><p></p><p> if (!item.IsFolder || (item.IsFolder && VirtualDirectory.IsImageFile(System.IO.Path.GetExtension(item.Path).ToLower())))</p><p> {</p><p> if (IsPicture(item.Path)) return;</p><p></p><p> strThumb = System.IO.Path.ChangeExtension(item.Path, ".jpg");</p><p></p><p> if (!System.IO.File.Exists(strThumb))</p><p> {</p><p> strThumb = System.IO.Path.ChangeExtension(item.Path, ".tbn");</p><p> if (!System.IO.File.Exists(strThumb))</p><p> {</p><p> strThumb = System.IO.Path.ChangeExtension(item.Path, ".png");</p><p> if (!System.IO.File.Exists(strThumb))</p><p> {</p><p> strThumb = GetThumb(item.Path);</p><p> if (!System.IO.File.Exists(strThumb))</p><p> return;</p><p> }</p><p> }</p><p> }</p><p></p><p> // now strThumb exists</p><p> item.ThumbnailImage = strThumb;</p><p> item.IconImage = strThumb;</p><p> item.IconImageBig = strThumb;</p><p> }</p><p> else</p><p> {</p><p> if (item.Label != "..")</p><p> {</p><p> strThumb = item.Path + @"\folder.jpg";</p><p> if (System.IO.File.Exists(strThumb))</p><p> {</p><p> item.ThumbnailImage = strThumb;</p><p> item.IconImage = strThumb;</p><p> item.IconImageBig = strThumb;</p><p> }</p><p> else</p><p> {</p><p> strThumb = String.Format(@"{0}\{1}.jpg", Thumbs.Folders, MediaPortal.Util.Utils.EncryptLine(item.Path));</p><p> if (System.IO.File.Exists(strThumb))</p><p> {</p><p> item.ThumbnailImage = strThumb;</p><p> item.IconImage = strThumb;</p><p> item.IconImageBig = strThumb;</p><p> }</p><p> }</p><p> }</p><p> }</p><p> if (!string.IsNullOrEmpty(strThumb))</p><p> {</p><p> strThumb = Util.Utils.ConvertToLargeCoverArt(strThumb);</p><p> if (System.IO.File.Exists(strThumb))</p><p> item.ThumbnailImage = strThumb;</p><p> }</p><p> }</p><p></p><p> public static bool CreateFolderPreviewThumb(List<string> aPictureList, string aThumbPath)</p><p> {</p><p> bool result = false;</p><p></p><p> if (aPictureList.Count > 0)</p><p> {</p><p> try</p><p> {</p><p> string currentSkin = GUIGraphicsContext.Skin;</p><p></p><p> // when launched by configuration exe this might be the case</p><p> if (string.IsNullOrEmpty(currentSkin))</p><p> {</p><p> using (Profile.Settings xmlreader = new Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml")))</p><p> {</p><p> currentSkin = Application.StartupPath + @"\skin\" + xmlreader.GetValueAsString("skin", "name", "BlueTwo");</p><p> }</p><p> }</p><p></p><p> string defaultBackground = currentSkin + @"\media\previewbackground.png";</p><p></p><p> if (File.Exists(defaultBackground))</p><p> {</p><p> using (Image imgFolder = Image.FromFile(defaultBackground))</p><p> {</p><p> int width = imgFolder.Width;</p><p> int height = imgFolder.Height;</p><p></p><p> int thumbnailWidth = 256;</p><p> int thumbnailHeight = 256;</p><p> // draw a fullsize thumb if only 1 pic is available</p><p> if (aPictureList.Count == 1)</p><p> {</p><p> thumbnailWidth = (width - 20);</p><p> thumbnailHeight = (height - 20);</p><p> }</p><p> else</p><p> {</p><p> thumbnailWidth = (width - 30) / 2;</p><p> thumbnailHeight = (height - 30) / 2;</p><p> }</p><p></p><p> using (Bitmap bmp = new Bitmap(width, height))</p><p> {</p><p> using (Graphics g = Graphics.FromImage(bmp))</p><p> {</p><p> g.CompositingQuality = Thumbs.Compositing;</p><p> g.InterpolationMode = Thumbs.Interpolation;</p><p> g.SmoothingMode = Thumbs.Smoothing;</p><p></p><p> g.DrawImage(imgFolder, 0, 0, width, height);</p><p> int x, y, w, h;</p><p> x = 0;</p><p> y = 0;</p><p> w = thumbnailWidth;</p><p> h = thumbnailHeight;</p><p> //Load first of 4 images for the folder thumb. </p><p> try</p><p> {</p><p> AddPicture(g, (string)aPictureList[0], x + 10, y + 10, w, h);</p><p> System.Threading.Thread.Sleep(30);</p><p></p><p> //If exists load second of 4 images for the folder thumb.</p><p> if (aPictureList.Count > 1)</p><p> {</p><p> AddPicture(g, (string)aPictureList[1], x + thumbnailWidth + 20, y + 10, w, h);</p><p> System.Threading.Thread.Sleep(30);</p><p> }</p><p></p><p> //If exists load third of 4 images for the folder thumb.</p><p> if (aPictureList.Count > 2)</p><p> {</p><p> AddPicture(g, (string)aPictureList[2], x + 10, y + thumbnailHeight + 20, w, h);</p><p> System.Threading.Thread.Sleep(30);</p><p> }</p><p></p><p> //If exists load fourth of 4 images for the folder thumb.</p><p> if (aPictureList.Count > 3)</p><p> {</p><p> AddPicture(g, (string)aPictureList[3], x + thumbnailWidth + 20, y + thumbnailHeight + 20, w, h);</p><p> System.Threading.Thread.Sleep(30);</p><p> }</p><p> }</p><p> catch (Exception ex)</p><p> {</p><p> Log.Error("Utils: An exception occured creating folder preview thumb: {0}", ex.Message);</p><p> }</p><p> }//using (Graphics g = Graphics.FromImage(bmp) )</p><p></p><p> try</p><p> {</p><p> if (System.IO.File.Exists(aThumbPath))</p><p> FileDelete(aThumbPath);</p><p></p><p> string tmpFile = Path.Combine(Path.GetTempPath(), "folderpreview.jpg");</p><p> if (System.IO.File.Exists(tmpFile))</p><p> FileDelete(tmpFile);</p><p></p><p> bmp.Save(tmpFile, System.Drawing.Imaging.ImageFormat.Jpeg);</p><p></p><p> using (Image thumbImage = Image.FromFile(tmpFile))</p><p> {</p><p> string folderHash = MediaPortal.Util.Utils.EncryptLine(Path.GetDirectoryName(aThumbPath));</p><p> aThumbPath = String.Format(@"{0}\{1}.jpg", Thumbs.Folders, folderHash);</p><p> if (Picture.CreateThumbnail(thumbImage, aThumbPath, (int)Thumbs.ThumbResolution, (int)Thumbs.ThumbResolution, 0, true))</p><p> {</p><p> System.Threading.Thread.Sleep(30);</p><p> // we do not want a folderL.jpg</p><p> if (!aThumbPath.ToLowerInvariant().Contains(folderHash + ".jpg"))</p><p> {</p><p> aThumbPath = Util.Utils.ConvertToLargeCoverArt(aThumbPath);</p><p> Picture.CreateThumbnail(thumbImage, aThumbPath, (int)Thumbs.ThumbLargeResolution, (int)Thumbs.ThumbLargeResolution, 0, false);</p><p> }</p><p> }</p><p></p><p> System.Threading.Thread.Sleep(30);</p><p> if (System.IO.File.Exists(aThumbPath))</p><p> result = true;</p><p> // File.SetAttributes(thumbnailImageName, FileAttributes.Hidden);</p><p> }</p><p> }</p><p> catch (Exception ex2)</p><p> {</p><p> Log.Error("Utils: An exception occured saving folder preview thumb: {0} - {1}", aThumbPath, ex2.Message);</p><p> }</p><p> }//using (Bitmap bmp = new Bitmap(210,210))</p><p> }</p><p> }</p><p> else</p><p> Log.Warn("Utils: Your skin does not supply previewbackground.png to create folder preview thumbs!");</p><p></p><p> }</p><p> catch (Exception exm)</p><p> {</p><p> Log.Error("Utils: An error occured creating folder preview thumbs: {0}", exm.Message);</p><p> }</p><p> } //if (pictureList.Count>0)</p><p> else</p><p> result = false;</p><p></p><p> return result;</p><p> }</p><p>[/code]</p></blockquote><p></p>
[QUOTE="toertchn, post: 221140, member: 63984"] The tracker submission is closed - I also found the way to hide the folder.jpg in filesystem not the best. To store folder thums in cache i modified "Core/Util/Thumbs.cs" [code] public static readonly string Folders = Config.GetSubFolder(Config.Dir.Thumbs, @"Folders"); public static void CreateFolders() { ... System.IO.Directory.CreateDirectory(Folders); ... } [/code] In the file "Core/Util/Util.cs" I modified 2 functions: [code] public static void SetThumbnails(ref GUIListItem item) { if (item == null) return; string strThumb = string.Empty; if (!item.IsFolder || (item.IsFolder && VirtualDirectory.IsImageFile(System.IO.Path.GetExtension(item.Path).ToLower()))) { if (IsPicture(item.Path)) return; strThumb = System.IO.Path.ChangeExtension(item.Path, ".jpg"); if (!System.IO.File.Exists(strThumb)) { strThumb = System.IO.Path.ChangeExtension(item.Path, ".tbn"); if (!System.IO.File.Exists(strThumb)) { strThumb = System.IO.Path.ChangeExtension(item.Path, ".png"); if (!System.IO.File.Exists(strThumb)) { strThumb = GetThumb(item.Path); if (!System.IO.File.Exists(strThumb)) return; } } } // now strThumb exists item.ThumbnailImage = strThumb; item.IconImage = strThumb; item.IconImageBig = strThumb; } else { if (item.Label != "..") { strThumb = item.Path + @"\folder.jpg"; if (System.IO.File.Exists(strThumb)) { item.ThumbnailImage = strThumb; item.IconImage = strThumb; item.IconImageBig = strThumb; } else { strThumb = String.Format(@"{0}\{1}.jpg", Thumbs.Folders, MediaPortal.Util.Utils.EncryptLine(item.Path)); if (System.IO.File.Exists(strThumb)) { item.ThumbnailImage = strThumb; item.IconImage = strThumb; item.IconImageBig = strThumb; } } } } if (!string.IsNullOrEmpty(strThumb)) { strThumb = Util.Utils.ConvertToLargeCoverArt(strThumb); if (System.IO.File.Exists(strThumb)) item.ThumbnailImage = strThumb; } } public static bool CreateFolderPreviewThumb(List<string> aPictureList, string aThumbPath) { bool result = false; if (aPictureList.Count > 0) { try { string currentSkin = GUIGraphicsContext.Skin; // when launched by configuration exe this might be the case if (string.IsNullOrEmpty(currentSkin)) { using (Profile.Settings xmlreader = new Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml"))) { currentSkin = Application.StartupPath + @"\skin\" + xmlreader.GetValueAsString("skin", "name", "BlueTwo"); } } string defaultBackground = currentSkin + @"\media\previewbackground.png"; if (File.Exists(defaultBackground)) { using (Image imgFolder = Image.FromFile(defaultBackground)) { int width = imgFolder.Width; int height = imgFolder.Height; int thumbnailWidth = 256; int thumbnailHeight = 256; // draw a fullsize thumb if only 1 pic is available if (aPictureList.Count == 1) { thumbnailWidth = (width - 20); thumbnailHeight = (height - 20); } else { thumbnailWidth = (width - 30) / 2; thumbnailHeight = (height - 30) / 2; } using (Bitmap bmp = new Bitmap(width, height)) { using (Graphics g = Graphics.FromImage(bmp)) { g.CompositingQuality = Thumbs.Compositing; g.InterpolationMode = Thumbs.Interpolation; g.SmoothingMode = Thumbs.Smoothing; g.DrawImage(imgFolder, 0, 0, width, height); int x, y, w, h; x = 0; y = 0; w = thumbnailWidth; h = thumbnailHeight; //Load first of 4 images for the folder thumb. try { AddPicture(g, (string)aPictureList[0], x + 10, y + 10, w, h); System.Threading.Thread.Sleep(30); //If exists load second of 4 images for the folder thumb. if (aPictureList.Count > 1) { AddPicture(g, (string)aPictureList[1], x + thumbnailWidth + 20, y + 10, w, h); System.Threading.Thread.Sleep(30); } //If exists load third of 4 images for the folder thumb. if (aPictureList.Count > 2) { AddPicture(g, (string)aPictureList[2], x + 10, y + thumbnailHeight + 20, w, h); System.Threading.Thread.Sleep(30); } //If exists load fourth of 4 images for the folder thumb. if (aPictureList.Count > 3) { AddPicture(g, (string)aPictureList[3], x + thumbnailWidth + 20, y + thumbnailHeight + 20, w, h); System.Threading.Thread.Sleep(30); } } catch (Exception ex) { Log.Error("Utils: An exception occured creating folder preview thumb: {0}", ex.Message); } }//using (Graphics g = Graphics.FromImage(bmp) ) try { if (System.IO.File.Exists(aThumbPath)) FileDelete(aThumbPath); string tmpFile = Path.Combine(Path.GetTempPath(), "folderpreview.jpg"); if (System.IO.File.Exists(tmpFile)) FileDelete(tmpFile); bmp.Save(tmpFile, System.Drawing.Imaging.ImageFormat.Jpeg); using (Image thumbImage = Image.FromFile(tmpFile)) { string folderHash = MediaPortal.Util.Utils.EncryptLine(Path.GetDirectoryName(aThumbPath)); aThumbPath = String.Format(@"{0}\{1}.jpg", Thumbs.Folders, folderHash); if (Picture.CreateThumbnail(thumbImage, aThumbPath, (int)Thumbs.ThumbResolution, (int)Thumbs.ThumbResolution, 0, true)) { System.Threading.Thread.Sleep(30); // we do not want a folderL.jpg if (!aThumbPath.ToLowerInvariant().Contains(folderHash + ".jpg")) { aThumbPath = Util.Utils.ConvertToLargeCoverArt(aThumbPath); Picture.CreateThumbnail(thumbImage, aThumbPath, (int)Thumbs.ThumbLargeResolution, (int)Thumbs.ThumbLargeResolution, 0, false); } } System.Threading.Thread.Sleep(30); if (System.IO.File.Exists(aThumbPath)) result = true; // File.SetAttributes(thumbnailImageName, FileAttributes.Hidden); } } catch (Exception ex2) { Log.Error("Utils: An exception occured saving folder preview thumb: {0} - {1}", aThumbPath, ex2.Message); } }//using (Bitmap bmp = new Bitmap(210,210)) } } else Log.Warn("Utils: Your skin does not supply previewbackground.png to create folder preview thumbs!"); } catch (Exception exm) { Log.Error("Utils: An error occured creating folder preview thumbs: {0}", exm.Message); } } //if (pictureList.Count>0) else result = false; return result; } [/code] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 1
Development
Improvement Suggestions
Hide Thumbs.jpg
Contact us
RSS
Top
Bottom