Convert Image to a VALID icon-VBForums
Results 1 to 7 of 7

Thread: Convert Image to a VALID icon

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2007
    Posts
    50

    Convert Image to a VALID icon

    I need help converting an image to a valid icon.

    I can save the image as an Icon, no problem. BUT, when I try to use this Icon for it's intended purpose (just as either a project icon, or shortcut icon) .. an error appears telling me it is not a valid icon.

    Code:
      
    Dim bmp As New Bitmap(Path & shortLabel & "\" & imgName)
    bmp.Save(Path & shortLabel & "\newIco.ico", System.Drawing.Imaging.ImageFormat.Icon)
    Any solutions? Ideally without needing extra DLLs that would have to be included with my project, but if that's what it requires then so be it.


    Thanks for your time.

  2. #2
    PowerPoster kaliman79912's Avatar
    Join Date
    Jan 2009
    Location
    Ciudad Juarez, Chihuahua. Mexico
    Posts
    2,592

    Re: Convert Image to a VALID icon

    What is the line where you are trying to use it?
    More important than the will to succeed, is the will to prepare for success.

    Please rate the posts, your comments are the fuel to keep helping people

  3. #3

    Thread Starter
    Member
    Join Date
    Apr 2007
    Posts
    50

    Re: Convert Image to a VALID icon

    No line, but manual.

    So once this program has ran and created the said Icon, I'm going into a different project in VS, and setting the projects icon within the project properties screen.

  4. #4
    PowerPoster kaliman79912's Avatar
    Join Date
    Jan 2009
    Location
    Ciudad Juarez, Chihuahua. Mexico
    Posts
    2,592

    Re: Convert Image to a VALID icon

    try something like

    Code:
    Dim xxx As New Bitmap(Path & shortLabel & "\" & imgName)
            Using ico As Icon = Icon.FromHandle(xxx.GetHicon())
                Using icoFile As System.IO.FileStream = New System.IO.FileStream(Path & shortLabel & "\newIco.ico", System.IO.FileMode.OpenOrCreate)
                    ico.Save(icoFile)
                End Using
            End Using
    More important than the will to succeed, is the will to prepare for success.

    Please rate the posts, your comments are the fuel to keep helping people

  5. #5
    PowerPoster kaliman79912's Avatar
    Join Date
    Jan 2009
    Location
    Ciudad Juarez, Chihuahua. Mexico
    Posts
    2,592

    Re: Convert Image to a VALID icon

    or use Imports System.IO and simplify the code

    Code:
    Dim bmp As New Bitmap(Path & shortLabel & "\" & imgName)
    Using ico As Icon = Icon.FromHandle(bmp.GetHicon())
       Using icoFile As FileStream = New FileStream(Path & shortLabel & "\newIco.ico", FileMode.OpenOrCreate)
           ico.Save(icoFile)
       End Using
    End Using
    More important than the will to succeed, is the will to prepare for success.

    Please rate the posts, your comments are the fuel to keep helping people

  6. #6

    Thread Starter
    Member
    Join Date
    Apr 2007
    Posts
    50

    Re: Convert Image to a VALID icon

    Still doesn't work... I can't figure out why, I've been trying various methods I've found laying around on the internet.... I'm puzzled!

  7. #7

    Thread Starter
    Member
    Join Date
    Apr 2007
    Posts
    50

    Re: Convert Image to a VALID icon

    I may of found a work around using an external application and command line.... Thank's for your help kaliman79912, I'll look further into my problem when I have time.

Tags for this Thread

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.