Results 1 to 8 of 8

Thread: Pics not fully loading

Threaded View

  1. #1

    Thread Starter
    Fanatic Member SeaHag's Avatar
    Join Date
    Jul 2001
    Location
    Lake Huron
    Posts
    901

    Pics not fully loading

    The cod i am using to load pictures into memory is not
    fully working.

    Its seem spuratic.... loading some ..sometimes.. then others..other times.

    Heres the code

    Im module mBitmap
    VB Code:
    1. Function LoadBitmap(iFileName As String) As Long
    2.     Dim A As Long
    3.    
    4.     If Dir(iFileName) = "" Then
    5.         'Error: File not found
    6.         LoadBitmap = -1
    7.        
    8.         Exit Function
    9.     End If
    10.    
    11.     'Check if already loaded
    12.     For A = 0 To BitmapCount
    13.         If Bitmap(A).FileName = LCase(iFileName) Then
    14.             'Bitmap already loaded
    15.             LoadBitmap = A
    16.                
    17.             Exit Function
    18.         End If
    19.     Next
    20.    
    21.     'Allocate memory
    22.     BitmapCount = BitmapCount + 1
    23.     ReDim Preserve Bitmap(BitmapCount)
    24.    
    25.     'Load file
    26.     LoadDC iFileName, Bitmap(BitmapCount)
    27.    
    28.     'Return index
    29.     If Bitmap(BitmapCount).DC > -1 Then
    30.         LoadBitmap = BitmapCount
    31.     Else
    32.         LoadBitmap = -1
    33.     End If
    34. End Function
    35.  
    36.  
    37.  
    38. Function LoadDC(iFileName As String, iBitmap As tBitmap) As Long
    39.     Dim DC As Long
    40.     Dim Temp As IPictureDisp
    41.    
    42.     'Create compatible DC
    43.     DC = CreateCompatibleDC(MainWindow.hdc)
    44.    
    45.     If DC < 1 Then
    46.         'Error: Can't create compatible DC
    47.         LoadDC = -1
    48.        
    49.         Exit Function
    50.     End If
    51.    
    52.     'Load bitmap
    53.     Set Temp = LoadPicture(iFileName)
    54.     SelectObject DC, Temp
    55.    
    56.     'Apply values
    57.     With iBitmap
    58.         .FileName = LCase(iFileName)
    59.        
    60.         .DC = DC
    61.     LoadDC = DC
    62.        
    63.         .W = MainWindow.ScaleX(Temp.Width)
    64.         .H = MainWindow.ScaleY(Temp.Height)
    65.     End With
    66.  
    67.    
    68.     'Release memory
    69.     DeleteObject Temp
    70.     Set Temp = Nothing
    71. End Function


    in form
    VB Code:
    1. mBitmap.Initialize Me
    2.     For A = 0 To 8
    3.         mBitmap.LoadBitmap App.Path & "\" & A & ".jpg"
    4.     Next
    5.    
    6.    
    7.     Dim i As Integer
    8.     For i = 0 To UBound(Bitmap)
    9.         List1.AddItem Bitmap(i).FileName
    10.     Next
    Any suggestions why this does not werk?


    Screen shot
    Attached Images Attached Images  

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