Results 1 to 7 of 7

Thread: [2005] scan pc for bitmaps and store in imagelist?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,547

    [2005] scan pc for bitmaps and store in imagelist?

    well here is wat i want to do.

    make my program scan for .bmp's and if it finds one it checks if its alrdy in the imagelist1 and if its not then it adds it. now my only problem is checking if the bmp is in the imagelist1. how would i do this? and make it fast?

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] scan pc for bitmaps and store in imagelist?

    Unless you visit the same file twice how can the same image already be in the ImageList? If you mean that there may be two copies of the same image in the file system then you'd have to compare either pixels or bytes of the current image to all images already in the collection. There's no way to make that genuinely fast that I'm aware of. I'd think the thing to do would be to simply add every image and if the user finds that they have duplicates because they had duplicates on their disc then let them remove them.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: [2005] scan pc for bitmaps and store in imagelist?

    VB Code:
    1. Public Class Form1
    2.     Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    3.         For Each iFile As String In IO.Directory.GetFiles("C:\Documents and Settings\Name\Desktop")
    4.             If IO.Path.GetExtension(iFile) = ".gif" AndAlso AlreadyImage(iFile) = False Then
    5.                 ImageList1.Images.Add(iFile, New Bitmap(iFile))
    6.             End If
    7.         Next
    8.     End Sub
    9.  
    10.     Private Function AlreadyImage(ByVal Picture As String) As Boolean
    11.         Dim tPic As New Bitmap(Picture)
    12.         For Each Item As String In ImageList1.Images.Keys
    13.             Dim MyPic As New Bitmap(Item)
    14.             If MyPic.GetPixel(MyPic.Width - 1, MyPic.Height - 1) = tPic.GetPixel(tPic.Width - 1, tPic.Height - 1) Then
    15.                 Return True
    16.             End If
    17.         Next
    18.     End Function
    19. End Class

    If someone has an actual way with the imagelist please post, I cannot figure it out.

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,547

    Re: [2005] scan pc for bitmaps and store in imagelist?

    Quote Originally Posted by jmcilhinney
    Unless you visit the same file twice how can the same image already be in the ImageList? If you mean that there may be two copies of the same image in the file system then you'd have to compare either pixels or bytes of the current image to all images already in the collection. There's no way to make that genuinely fast that I'm aware of. I'd think the thing to do would be to simply add every image and if the user finds that they have duplicates because they had duplicates on their disc then let them remove them.
    well im making a program to get and display every single file icon. thats y i dont want them added twice.

  5. #5
    Addicted Member
    Join Date
    May 2006
    Posts
    142

    Re: [2005] scan pc for bitmaps and store in imagelist?

    what all tools should be added?

  6. #6
    Hyperactive Member Coool's Avatar
    Join Date
    Feb 2006
    Location
    System.Coool
    Posts
    333

    Re: [2005] scan pc for bitmaps and store in imagelist?

    if u want to collect the icons of all type of files exists on the HDD, then it's easy ..

    If Not ImageList1.Images.ContainsKey(fileExtension) Then
    ImageList1.Images.Add(fileExtension,Icon.ExtractAssociatedIcon(filePath).ToBitmap)
    End If
    I am using .NET 2010 with Windows 7

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] scan pc for bitmaps and store in imagelist?

    Scanning for BMP files isn't going to get you any icons. They are not related. Are you saying that you want to get all the file type icons in use on your machine or every ICO file or what? Just like for the BMPs, just because two icons look the same doesn't make them the same icon. You'd still have to do a pixel by pixel comparison. Don't forget also that ICO files can contain more than one icon, plus you also have ICL files, which can contain multiple sets of multiple icons.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

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



Click Here to Expand Forum to Full Width