load images-VBForums
Results 1 to 6 of 6

Thread: load images

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2011
    Posts
    5

    load images

    Hi everyone,
    i got application which allows users to choose images from their own locations in computer and application has button add. when they click it the picture is displayed and starts to rotate as in carousel. i would like to add some images that would be preloaded. would it be possible to use this application for that?d (VB.Net was used to build initial application). Thank you.

  2. #2

    Thread Starter
    New Member
    Join Date
    Feb 2011
    Posts
    5

    Re: load images

    forgot to mention. Silverlight 4 was used for building application.

  3. #3
    Frenzied Member Lightning's Avatar
    Join Date
    Oct 2002
    Location
    Eygelshoven
    Posts
    1,569

    Re: load images

    If you have the source it's no problem
    VB6 & C# (WCF LINQ) mostly


    If you need help with a WPF/WCF question post in the NEW WPF & WCF forum and we will try help the best we can

    My site

    My blog, couding troubles and solutions

    Free online tools

  4. #4

    Thread Starter
    New Member
    Join Date
    Feb 2011
    Posts
    5

    Re: load images

    Here is the code I was using

    Code:
    Partial Public Class Carousel
        Inherits UserControl
        Private Rotation As New Storyboard
        Private Images As New List(Of ImageSource)
        Private Items As New List(Of CarouselItem)
        Private Position As Point
        Private Radius As Point = New Point With {.X = 150, .Y = -40}
        Private Speed As Double = 0.0125
        Private Perspective As Double = 200
        Private Distance As Double
    
    
    
    
        Private Sub Populate(ByRef Canvas As Canvas)
            Canvas.Children.Clear()
            For Each image In Images
                Dim index As Integer
                Dim item As New CarouselItem
                item.Image.Source = image
                item.Angle = index * ((Math.PI * 2) / Images.Count)
                Position.X = Math.Cos(item.Angle) * Radius.X
                Position.Y = Math.Sin(item.Angle) * Radius.Y
                Canvas.SetLeft(item, Position.X)
                Canvas.SetTop(item, Position.Y)
                Distance = 1 / (1 - (Position.Y / Perspective))
                item.ItemScale.ScaleY = Distance
                item.ItemScale.ScaleX = item.ItemScale.ScaleY
                item.Opacity = item.ItemScale.ScaleX
                Items.Add(item)
                Canvas.Children.Add(item)
                index += 1
            Next
        End Sub
    
    
    
    
    
        Private Sub Rotate()
            For Each item As CarouselItem In Items
                item.Angle -= Speed
                Position.X = Math.Cos(item.Angle) * Radius.X
                Position.Y = Math.Sin(item.Angle) * Radius.Y
                Canvas.SetLeft(item, Position.X)
                Canvas.SetTop(item, Position.Y)
                If Radius.Y >= 0 Then
                    Distance = 1 * (1 - (Position.Y / Perspective))
                    Canvas.SetZIndex(item, CInt(Position.Y))
                Else
                    Distance = 1 / (1 - (Position.Y / Perspective))
                    Canvas.SetZIndex(item, CInt(Position.Y))
                End If
                item.ItemScale.ScaleY = Distance
                item.ItemScale.ScaleX = item.ItemScale.ScaleY
                item.Opacity = item.ItemScale.ScaleX
            Next
            Rotation.Begin()
    
        End Sub
    
        Public Sub Add(ByVal Source As ImageSource)
            Images.Add(Source)
    
            Populate(Display)
        End Sub
    
        Public Sub RemoveLast()
            If Images.Count > 0 Then
                Images.RemoveAt(Images.Count - 1)
                Populate(Display)
            End If
        End Sub
    
        Public Sub Clear()
            Images.Clear()
            Populate(Display)
        End Sub
    
    
        Public Sub New()
            InitializeComponent()
            Canvas.SetLeft(Display, Container.Width / 2 - Display.Width / 2)
            Canvas.SetTop(Display, Container.Height / 2 - Display.Height / 2)
            AddHandler Rotation.Completed, AddressOf Rotate
            Rotation.Begin()
        End Sub
    
        
    
        Private Function ImageMedium() As Object
            ImageMedium.Source = New System.Windows.Media.Imaging.BitmapImage(New Uri("/images/image1.png", UriKind.Absolute))
        End Function
    
    
    End Class
    If somebody could help me with it I would be very appreciated. I need my images to be loaded from the images folder. Thank you
    Last edited by gep13; Mar 10th, 2011 at 06:54 AM. Reason: Added Code Tags

  5. #5
    Frenzied Member MattP's Avatar
    Join Date
    Dec 2008
    Location
    WY
    Posts
    1,227

    Re: load images

    Initialize your Images List with the images you want to start with and call Populate in the constructor.

  6. #6
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,962

    Re: load images

    pikosan,

    When you are posting code into the forum, can you please remember to surround it in [code][/code] or [HIGHLIGHT=vb][/highlight] tags? It makes it a lot easier to read.

    I have edited your posted to do this.

    Thanks

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.