- December 6, 2004
- 2,055
- 318
I just took a brief look at the source code of MyPicture section of MP.
It seams that the integration becomes more complicated as I thought.
From my brief research I did not found a method that allows me to set the shown Thumb in the facadeView at runtime without loading a file from disk. All available methods seem to based on loading files (thumbs) from the harddrive, but that (of course) will slow down the whole routine because I have to save the thumb just to load it afterwards.
I've found the implementation of the OnRetrieveCoverArt. At this point it would easy to "turn to" my ExifExtractor to check if the item has an embedded and retrieve it. But how can I assign the retrieved image the the facadeView?
I tried something like this for testing (in the OnRetrieveCoverArt):
But item.Thumbnail is always null. And create new GUIImage seems to need a filename again ...Code:Bitmap tmpBitmap = new Bitmap(160, 120); Graphics tmpGraphics = Graphics.FromImage(tmpBitmap); tmpGraphics.FillEllipse(Brushes.Red,new Rectangle( 0, 0, 160, 120)); System.Drawing.Image img = (Image)tmpBitmap.Clone(); item.Thumbnail.MemoryImage = img;
The following code does work (Of course)... but this no solution.
Code:Bitmap tmpBitmap = new Bitmap(160, 120); Graphics tmpGraphics = Graphics.FromImage(tmpBitmap); tmpGraphics.FillEllipse(Brushes.Red,new Rectangle( 0, 0, 160, 120)); System.Drawing.Image img = (Image)tmpBitmap.Clone(); img.Save("C:\\test.jpg", ImageFormat.Jpeg); string thumbnailImage = "C:\\test.jpg"; item.ThumbnailImage = thumbnailImage;
Any ideas?
Bye
Lars
You'll have to use the Texturemanager to convert the bitmap to a texture and then load that texture to the control. But you need to make sure they get unloaded too when you don't need them anymore or the memory usage will go through the roof.
Something like:
Code:
System.Drawing.Image img = whatever.LoadImage();
string name = "whatever"; // unique per thumbnail, perhaps use the path
Size s = new Size(100,100);
item.ThumbnailImage = buildMemoryImage(img, name, s);
public static string buildMemoryImage(System.Drawing.Bitmap image, string identifier, System.Drawing.Size size)
{
string name = String.Format("[Thumbnail:{0}]", identifier);
try
{
if (GUITextureManager.LoadFromMemory(null, name, 0, 0, 0) == 0)
{
GUITextureManager.LoadFromMemory(image, name, 0, size.Width, size.Height);
}
}
catch (Exception ex)
{
// error
}
return name;
}
for me it works only if I specify a folder with jpg inside of it.
If I specify the folder above that, eg multiple folders the program just sits their doing nothing after i press start
Because it doesnt search recursivly, its just a test app