Results 1 to 6 of 6

Thread: can anything load images faster than loadpicture?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2001
    Posts
    26

    can anything load images faster than loadpicture?

    The following code is from Fox's web page:

    'Load bitmap
    Set Temp = LoadPicture(iFileName)
    SelectObject DC, Temp

    'Apply values
    LoadDC = DC 'Return the device context


    I'm using it in a program of mine, but it's kinda slow because I am putting it in part of a loop that loads an image based on X,Y corrodinates. The no 2 corrodinates have the same image.

    Is there another way to load an image to memory? maybe with API?

  2. #2
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    You can just set it in an array of imageboxes at the start, it will take longer to load but..! It will go FAST FAST FAST when you execute the program!
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Apr 2001
    Posts
    26
    that'd work fine for a small number of different images, but my program uses hundreds of different images, I have the program load about 12 images and draw them to the screen. Drawing them to the screen is nice and quick with bltbit, but loading them is slow as hell.

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    if you are using compressed file formats like jpeg or gif, try convert them to bmp's first, that will reduce the time to load upto 10 times. Loadpicture should do the approach about as fast as manual get# and createDIBitmap so i don't think you win anything that way.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5
    Member
    Join Date
    May 2001
    Location
    New Zealand
    Posts
    45

    Talking

    Dude I know a MUCH faster way than those [Well sorta]

    Code:
    Private Declare Function SelectObject Lib "gdi32" (ByVal hDC As Long, ByVal hObject As Long) As Long
    Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hDC As Long) As Long
    Private Declare Function DeleteDC Lib "gdi32" (ByVal hDC As Long) As Long
    Private Declare Function LoadImage Lib "user32" Alias "LoadImageA" (ByVal hInst As Long, ByVal lpsz As String, ByVal un1 As Long, ByVal n1 As Long, ByVal n2 As Long, ByVal un2 As Long) As Long
    Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
    
    'Constants for the GenerateDC function
    '**LoadImage Constants**
    Const IMAGE_BITMAP As Long = 0
    Const LR_LOADFROMFILE As Long = &H10
    Const LR_CREATEDIBSECTION As Long = &H2000
    Const LR_DEFAULTSIZE As Long = &H40
    '****************************************
    
    Public Function GenerateDC(FileName As String, ByRef MemDC As Long, ByRef hBitmap As Long) As Long
    
    'Create a Device Context, compatible with the screen
    MemDC = CreateCompatibleDC(0)
    
    If MemDC = 0 Then
        GenerateDC = 0
        Exit Function
    End If
    
    'Load the image
    hBitmap = LoadImage(0, FileName, IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE Or LR_LOADFROMFILE Or LR_CREATEDIBSECTION)
    
    If hBitmap = 0 Then 'Failure in loading bitmap
        DeleteDC MemDC
        Exit Function
    End If
    
    'Throw the Bitmap into the Device Context
    SelectObject MemDC, hBitmap
    
    'Return OK
    GenerateDC = 1
    
    End Function
    'Deletes a generated DC
    Private Function DeleteGeneratedDC(hBitmap As Long, MemDC As Long) As Long
    
    DeleteGeneratedDC = DeleteDC(MemDC)
    DeleteObject hBitmap
    
    End Function

  6. #6
    New Member
    Join Date
    Jan 2002
    Posts
    1

    what about .res files?

    Hi Extra-C!
    I totally agree. It's exactly the code I'm using to work with bmp.
    But what if your bitmaps are in .res file attached to your project?
    I tried every "permutation" in the api call but no results: I can't get that f... handle!!!

    Please help!
    Thanks in advance

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