Results 1 to 4 of 4

Thread: Storing .JPG pictures in a resource file

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Location
    Ont, Canada, Earth
    Posts
    458
    Hi,
    I know that I can store Bitmaps, Cursors and Icons in a resource files. Can I also store .JPG files?
    If not, how can I store 5 .JPG files in my app without first assinging them to 5 image controls and show/hide them?

    Thanks.
    Thanks

    Tomexx.

  2. #2
    Guest
    Put them in a RES file, but instead of loading them as a Bitmap, load them as a Custom resource.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Location
    Ont, Canada, Earth
    Posts
    458
    Thanks Megatron,
    How do I do that? The following doesn't work...

    imgBackImg.Picture = LoadResPicture(1, CUSTOM)

    Should I replace 'CUSTOM' with something else?

    Thanks.
    Thanks

    Tomexx.

  4. #4
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    Here you go:
    Code:
    Public Sub RunPictureFromResource(pintResourceID As Integer, pPictureBox As PictureBox)
        Dim bytArr() As Byte
        Dim intFFN As Integer
        Dim strPath As String
    
        bytArr = LoadResData(pintResourceID, "CUSTOM")
        strPath = App.Path & IIf(Right(App.Path, 1) = "\", MyPicture.tmp", "\MyPicture.tmp")
        intFFN = FreeFile
        Open strPath For Binary As intFFN
        Put #intFFN, , bytArr
        Close #intFFN
        pPictureBox = LoadPicture(strPath)
        Kill strPath
    End Sub
    Then call this function like this:

    Call RunPictureFromResource(101, Picture1)

    Where
    101 - is a resource ID
    Picture1 - is a name of the PictureBox

    [Edited by Serge on 08-17-2000 at 09:39 PM]

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