Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > CoverFlow > CoverFlow not work with MemoryStream why?

Not answered CoverFlow not work with MemoryStream why?

Feed from this thread
  • xax_007 avatar

    Posted on Dec 16, 2009 (permalink)

    Hello,

    I´m testing CoverFlow but i transform the Bytes[] from database, to image with MemoryStream, BitmapImage etc...

    But the images show a little seconds but after disappers, this is a CoverFlow problem or is my code?

    //GLOBAL VARIABLES  
            List<Byte[]> lB = new List<byte[]>();  
     
            List<Byte[]> lbuffer = new List<byte[]>();  
     
            ObservableCollection<Image> lI = new ObservableCollection<Image>();  
     
            List<MemoryStream> lMS = new List<MemoryStream>();  
     
            List<BitmapImage> lBM = new List<BitmapImage>();  
     
            Object o = new object();  
     
    void client_GetImagesSFCompleted(object sender, ImagesLibraryView.GetImages.GetImagesSFCompletedEventArgs e)  
            {  
                o = e.Result.Clone();  
     
                foreach (Object img in (Object[])o)  
                {  
                    lB.Add((Byte[])img);  
                }  
     
                foreach (Byte[] bA in lB)  
                {  
                    MemoryStream mS = new MemoryStream(bA);  
     
                    mS.Write(bA, 0, bA.Length);  
     
                    lMS.Add(mS);  
                }  
     
                foreach (MemoryStream mS in lMS)  
                {  
                    BitmapImage imgBM = new BitmapImage();  
     
                    imgBM.SetSource(mS);  
     
                    lBM.Add(imgBM);  
                }  
     
                foreach (BitmapImage bmI in lBM)  
                {  
                    Image I = new Image();  
                    I.Width = 200;  
                    I.Height = 200;  
                    I.Stretch = Stretch.None;  
                    I.Source = bmI;  
                      
                    lI.Add(I);  
                }  
     
                CoverFlow.ItemsSource = lI;  
     
            } 

    I get an array of images in e.Result, this is a reply of webservice Async and my images are in jpg, all is correctly.

    Reply

  • Valeri Hristov Valeri Hristov admin's avatar

    Posted on Dec 17, 2009 (permalink)

    Hello,

    If RadCoverFlow is populated with Image elements, in order to provide loading animation, it attaches event handler on the ImageLoaded event of each image. I suppose that when the ImageSource is loaded from a MemoryStream, the ImageLoaded event is not fired, hence RadCoverFlow does not display the image. I would recommend trying to wrap each image in a Border - this will prevent RadCoverFlow from attaching handlers on those events and will display the images without loading animation. Other option would be to add the ImageSource objects to the ItemsSource collection of RadCoverFlow and provide a ItemTemplate, containing the data-bound image.

    All the best,
    Valeri Hristov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

    Reply

  • phlogiston avatar

    Posted on Jan 12, 2010 (permalink)

    Hi,

    I suppose i have an identical problem; my Images come as a list of Byte[] through WCF-Service.
    I set them as source for MemoryStreams and those again as source for BitmapImages, who themselves become sources for Images,
    obviously just like xax_007 did.
    The control loads, i can see the pictures for a second, then it continues to show only the loading animation.
    Besides you are right, Valeri, the ImageLoaded event never gets fired in this example.

    As you suggested, i tried to wrap a border around any image, which had no effect...

    Other option would be to add the ImageSource objects to the ItemsSource collection of RadCoverFlow and provide a ItemTemplate, containing the data-bound image.

    I am very new to this, could you please explain that a bit further?

    many thx in advance.

    Reply

  • phlogiston avatar

    Posted on Jan 13, 2010 (permalink)

    Thanks for any possible effort, but i was able to solve my problem.

    It is now indeed working with the DataContext property set.

    But anyway, i will stick to using the filepaths instead of Byte[]'s since loading would take too long.

    best wishes!

    Reply

  • xax_007 avatar

    Posted on Jan 13, 2010 (permalink)

    this:

    Other option would be to add the ImageSource objects to the ItemsSource collection of RadCoverFlow and provide a ItemTemplate, containing the data-bound image.


    I think that can be a solution.

    But finally I create image to directory of my IIS, and in coverflow in my list of items source binding a string url for image...

    I don´t like this option because i have got to do a batch process for delete after the images..

    Thanks phlogiston.

    Salu2,
    Pablo

    Reply

  • Helen avatar

    Posted on Feb 13, 2010 (permalink)

    Could you tell me how you got this to work?

    I want to do the exact same thing.

    Thanks a bunch,

    Helen

    Reply

  • xax_007 avatar

    Posted on Feb 14, 2010 (permalink)

    Hello Helen,

    If use sitefinity for downloads images you have the url for the image in database, you can use this...

    Whit other source, you can use bitmap in silverlight, maybe can work..

    what scenay you have?

    Salu2,
    Pablo

    Reply

  • phlogiston avatar

    Posted on Feb 15, 2010 (permalink)

    Hello Helen,

    Here's an example of how i got CoverFlow to display my images:

    XAML:

    <telerikNavigation:RadCoverFlow x:Name="cfTest" ItemsSource="{Binding}" >
                <telerikNavigation:RadCoverFlow.ItemTemplate>
                    <DataTemplate>
                            <Image Source="{Binding FullPath}" Width="350" Height="350" Stretch="Uniform" />
                    </DataTemplate>
                </telerikNavigation:RadCoverFlow.ItemTemplate>
            </telerikNavigation:RadCoverFlow>

    and Code Behind:

    // This is the Callback of my GetImages WCF-Service call
    private void client_GetImagesCompleted(object sender, GetImagesCompletedEventArgs e)
    {
            cfTest.DataContext = e.Result;
    }

    In my case the Result here is a List of my custom Image-Class which consists only of the imagename and a property named FullPath, storing the absolute path to the image. In XAML you tell CoverFlow that the binding will follow at runtime, as well as which property of the binding will be the final imagesource.
    As i have tested before, this works as well with Byte[]'s if you convert them to "Image" as Pablo has done.

    Hope this is helpful; Best regards,

    Phlogiston

    Reply

  • Helen avatar

    Posted on Feb 15, 2010 (permalink)

    Thank you, that makes perfect sense.

    In my case I too get a byte array for the images, and that was the part I wanted to make sure it could handle.

    Cheers,

    Helen

    Reply

  • DragonBall avatar

    Posted on May 12, 2010 (permalink)

    <telerik:RadCoverFlow OffsetY="60" x:Name="CoverFlow1"  ItemsSource="{Binding}" > 
                <telerik:RadCoverFlow.ItemTemplate> 
                    <DataTemplate>                
                        <local:Cover Width="225" Height="225"></local:Cover> 
                    </DataTemplate> 
                </telerik:RadCoverFlow.ItemTemplate> 
            </telerik:RadCoverFlow> 
    and local:Cover is a usercontol with Image control
     <Image x:Name="CoverFlowControl" Source="{Binding ImageSources}"  Stretch="Fill" ImageFailed="Image_ImageFailed"  telerikNavigation:RadCoverFlow.EnableLoadNotification="True" /> 
    Calls The GetHistoryImage Method
    I am binding it though
     this.DataContext = LocalHistoryCollection.HistoryCollection ; 

    My class is
     public  class LocalHistoryCollection
        {

            public static List<LocalHistoryItem> HistoryCollection { get; set; }

        }

    public class LocalHistoryItem 
        { 
     
        
            public BitmapImage ImageSources { get; set; } 
            public string Title { get; set; } 
            public int ThumbImageWidth { get; set; } 
            public int ThumbImageHeight { get; set; } 
            public string Description { get; set; } 
            public LocalHistoryItem() 
            { 
                ImageSources = new BitmapImage(); 
            } 
     
        } 


     public  BitmapImage GetHistoryImage(string filename) 
            { 
                BitmapImage bi = new BitmapImage(); 
                try 
                { 
     
                    using (var store = IsolatedStorageFile.GetUserStoreForApplication()) 
                    { 
     
                        if (store.FileExists(string.Format("{0}.jpg", filename))) 
                        { 
                            using (isoStream = store.OpenFile(string.Format("{0}.jpg", filename), FileMode.Open)) 
                            { 
                                bi.SetSource(isoStream); 
                                return bi; 
     
                            } 
     
                        } 
                    } 
                } 
                catch (IsolatedStorageException ex) 
                { 
                    return bi; 
                } 
                return bi; 
                    
             } 
    The problem is, its always on loading animation. it does not load the images

    Reply

  • DragonBall avatar

    Posted on May 12, 2010 (permalink)

    problem solved i just remote the telerikNavigation:RadCoverFlow.EnableLoadNotification="True" from the Image control.

    Reply

  • Daniela avatar

    Posted on Sep 16, 2011 (permalink)

    This solution did not work for me, can you please upload more from your code?
    some help would be really appreciated,

    kind regards,

    Reply

  • Daniela avatar

    Posted on Sep 16, 2011 (permalink)

    @phlogiston

    This solution did not work for me, can you please upload more from your code?
    some help would be really appreciated,

    kind regards,

    Reply

  • Daniela avatar

    Posted on Sep 19, 2011 (permalink)

    does any one from telerik know the solution? any help would be very appreciated.

    Reply

  • Miroslav Nedyalkov Miroslav Nedyalkov admin's avatar

    Posted on Sep 20, 2011 (permalink)

    Hello Daniela,

    We don't know what problem you are experiencing and without a project that demonstrates it, we are shooting in the dark. What I could suggest you is to try to load the images without a CoverFlow control - this could help you to isolate the problem you are experiencing. This post could be helpful.

    Kind regards,
    Miroslav Nedyalkov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

    Reply

  • Daniela avatar

    Posted on Sep 28, 2011 (permalink)

    Hi,

    thanks a lot for your reply, I could fix the error. I was not getting the correct image folder in the server. this is the code in case some one can use it:
    FullPath = HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Host + ":" + HttpContext.Current.Request.Url.Port + "/imageFolderInTheServer/" + pictureName;

    Kind Regards,

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > CoverFlow > CoverFlow not work with MemoryStream why?
Related resources for "CoverFlow not work with MemoryStream why?"

Silverlight CoverFlow Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  ]