Results 1 to 14 of 14

Thread: *resolved* HELPPPPPP How can I add images to my program?

  1. #1

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    *resolved* HELPPPPPP How can I add images to my program?

    any way to do this besides using an image list? I have about 200 SMALL pictures that I need to add to my program and the stupid image list doesnt let me to select them all at once.... it would take a year to add them all
    How could I add those images? (I want them to be included in the exe file, or possibly in a single resource file that can be used by my app, but I have no idea how to do this)(
    Last edited by MrPolite; Apr 13th, 2003 at 09:11 PM.
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  2. #2
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    Yes use a resource file. Cant give you an an example now, since my workstation is fried. I lost all my work that I've been working on for the last year and a half. I'm just starting to recover
    Dont gain the world and lose your soul

  3. #3
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Damn that sucks DevGrp! You have to build the ResourceMaker application from the samples so you have a Resource Editor. Then you just add things to it and save as a file. Then include that file in your project. You can retrieve objects from it via the ResourceManager object.

    http://www.vbforums.com/showthread.p...hreadid=169258
    http://www.vbcity.com/forums/topic.asp?tid=7503
    http://www.vbcity.com/forums/topic.asp?tid=17412

    If you are still stuck then let me know and I'll do up a sample.
    Last edited by Edneeis; Apr 12th, 2003 at 07:10 PM.

  4. #4

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    hmm I dont get it, what's that "ResourceMaker" that you're talking about? sounds like those posts will tell me how to read a resource, but can you tell me how to make one first?

    DevGrp, sorry to hear about that, loosing data really sucks. Was it your programs that you lost?
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  5. #5
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    Yeah it does suck. Now I'm on a strict backup schedule.
    Dont gain the world and lose your soul

  6. #6

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    Originally posted by DevGrp
    Yeah it does suck. Now I'm on a strict backup schedule.
    I've lost data many times... but most of the times they were worthless, hehe

    anyways... I made a little program that makes resx files.. I added a series of images in the file and I can see them as a table in VS. I hope I can get it to work now


    edit: IF THIS WORKS, should I change the Build Action for the resx file to "compile"? or should I leave it as Embedded Resource?


    edit#2 hehe how do I get this to work!! the thing is that I DONT know the name of each resource in the resource file. So what I want to do is to load all the images that are in the resource file. I've added the resx file to my project, is this how I load it?

    Dim rm As New ResourceManager("MyApp.MyResStrings", System.Reflection.Assembly.GetExecutingAssembly())


    what should I do to load the images?
    Last edited by MrPolite; Apr 12th, 2003 at 11:38 PM.
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  7. #7

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    umm I made a resx file and then converted it to a resource file. I still dont know how I cant load the images without knowing the field names
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  8. #8
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Why don't you know the fieldnames?

  9. #9
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    well..create a folder called pictures(just to not mess up all your project) then drag and drop ALL pictures to that folder and there is somewhere a option that will embedded them in the .EXE..hope this helps
    edit: omg i suck, now i see that this already had been talked about..i have somewhere a function in VB.NET which gets a resource ill look up for it wait some min plz
    edit2: hope this helps,
    VB Code:
    1. Private Function GetResource(ByVal filename As String) As System.IO.Stream
    2.         Dim oAssembly As Reflection.Assembly = MyClass.GetType.Assembly
    3.         Dim sFiles() As String
    4.         Dim sFile As String
    5.         ' prefix filename with namespace
    6.         filename = oAssembly.GetName.Name & "." & filename
    7.         ' get a list of all embeded files
    8.         sFiles = oAssembly.GetManifestResourceNames()
    9.         ' loop through each file
    10.         For Each sFile In sFiles
    11.             ' found the file? return the stream
    12.             If sFile = filename Then
    13.                 Return oAssembly.GetManifestResourceStream(sFile)
    14.             End If
    15.         Next
    16.     End Function
    Last edited by PT Exorcist; Apr 13th, 2003 at 07:48 AM.
    \m/\m/

  10. #10

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    hmm I couldnt do much with yuor code pt exorcist, but thanks anyways.

    now lets say I force myself to know the field names now what? how can I get the resources?because I tried it and it didnt work. The resource that I have is called tmp.resources and here's what I did:

    VB Code:
    1. Dim rm As New ResourceManager("tmp", System.Reflection.Assembly.GetExecutingAssembly())
    2.         Dim bmp As Bitmap = CType(rm.GetObject("what", Globalization.CultureInfo.CurrentCulture), Bitmap)
    3.         picturebox1.image = bmp
    it stops on the second line ,and here's the error:

    An unhandled exception of type 'System.Resources.MissingManifestResourceException' occurred in mscorlib.dll

    Additional information: Could not find any resources appropriate for the specified culture (or the neutral culture) in the given assembly. Make sure "tmp.resources" was correctly embedded or linked into assembly "WindowsApplication36".
    baseName: tmp locationInfo: <null> resource file name: tmp.resources assembly: WindowsApplication36, Version=1.0.1198.19709, Culture=neutral, PublicKeyToken=null
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  11. #11
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    The basename of the resource should be the namespace plus the filename of the resource. Also it seems to work more with .resources files instead of .resx.

    VB Code:
    1. Dim rm As New ResourceManager("MyNamespace.MyEbeddedFilename", System.Reflection.Assembly.GetExecutingAssembly())
    2.         Dim bmp As Bitmap = CType(rm.GetObject("what", Globalization.CultureInfo.CurrentCulture), Bitmap)
    3.         picturebox1.image = bmp

    I have attached an example.

  12. #12

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    I changed the first line and it worked thanks alot! I wish there was a way to get all the resources without having their field names, but sounds like there isn't. Oh well...
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  13. #13
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by DevGrp
    Yes use a resource file. Cant give you an an example now, since my workstation is fried. I lost all my work that I've been working on for the last year and a half. I'm just starting to recover
    Sorry to hear that DevGrp . I know how you feel now .Use DataFinal 2.0 (I think I have the final version) to recover all of your lost data . If you need it just let me know .

  14. #14

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    Hey yo! Easy Data Recovery is the best.
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

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