MediaPortal Forums HTPC/MediaCenter

Go Back   MediaPortal Forum » MediaPortal 1 » Help on Development » Quality Assurance (Bugreports) » Archive » Bug Reports » 0.2.0.0 Final and SVN Builds » fixed 0.2.0.0 bugs


fixed 0.2.0.0 bugs Bugreports that have been resolved will be moved in here.

Reply
 
Thread Tools Display Modes
Old 2006-11-18, 20:11   #1 (permalink)
Portal Member
 
Join Date: Jan 2005
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts


fixed MyPictures - Blank pics when viewing shares [SVN 11182006]

This is my first (bug?) post so not sure if this is where it goes. This is the temporary fix I came up with - which I know you guys can implement a better, more generic code for.

When viewing pictures stored in windows shares I get blank pics. Mediaportal.log reported an exception in picture.load stating that it was an access denial error with the picture. Even after allowing full rights with the share the same error occured. After doing some digging the problem seemed to boil down to Util\Pictures.cs Load(string strPic,....) function. The problem was with the code

Code:
using (FileStream stream = new FileStream(strPic, FileMode.Open))
line. It kept throwing the exception.

So I decided to change the code to:
Code:
using (FileStream stream = new FileStream(strPic, FileMode.Open, FileAccess.Read))
Still the same problem occured.

Turns out the problem has something to do with the stream outlined in http://www.pixvillage.com/blogs/devb...03/09/154.aspx

I created a new class from the code referenced in the above link and called it StreamedImage.cs and placed it in the util directory. Here is the code:

Code:
using System;
using System.Drawing;
using System.IO;

namespace MediaPortal.Util
{
    public class StreamedImage : IDisposable
    {
        private Image image;
        private Stream stream;

        public StreamedImage(Stream stream, bool useEmbeddedColorManagement, bool validateImageData)
        {
            this.stream = stream;
            this.image = System.Drawing.Image.FromStream(stream, useEmbeddedColorManagement, validateImageData);
        }

        public Image Image
        {
            get { return image; }
        }


        public Stream Stream
        {
            get { return stream; }
        }

        public void Dispose()
        {
            if (image != null)
            {
                image.Dispose();
                image = null;
            }

            if (stream != null)
            {
                stream.Close();
                stream = null;
            }
        }
    }
}
In Picture.cs load function, I changed the line of code
Code:
using (FileStream stream = new FileStream(strPic, FileMode.Open))
to
Code:
StreamedImage sim = new StreamedImage(new FileStream(strPic, FileMode.Open, FileAccess.Read), true, false);
below that there was a variable theImage referencing the image from the original stream:
Code:
theImage = Image.FromStream(stream, true, false);
.

This was changed to:
Code:
theImage = sim.Image;
I recompiled MP and put that code into play. Fixed my problem. I'm not sure if this was the exact right approach but it worked for me.
htpcNoob is offline   Reply With Quote
Reply

Bookmarks

Tags
blank, mypictures, pics, shares, viewing

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Failed to start timeshifting Unable to create graph Topher5000 General Support 31 2008-09-06 18:35
TV recording question/problem 'Arry Installation, configuration support 9 2006-09-22 14:14
Recording from TV 'Arry General Support 2 2006-09-20 01:12
MyPictures goes white after displaying a random nmbr of pics strawberry General Support 6 2006-07-31 21:25
Cant get MyTV to work (2.0 RC3)? mdolan General Support 3 2006-03-30 15:58


All times are GMT +1. The time now is 09:28.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 Protected by Akismet Blog with WordPress
Advertisement System V2.6 By   Branden