|
-
May 4th, 2001, 06:57 PM
#1
Thread Starter
Junior Member
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?
-
May 4th, 2001, 07:19 PM
#2
Good Ol' Platypus
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)
-
May 4th, 2001, 07:32 PM
#3
Thread Starter
Junior Member
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.
-
May 5th, 2001, 07:05 AM
#4
transcendental analytic
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.
-
May 7th, 2001, 12:22 AM
#5
Member
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
-
Jan 4th, 2002, 10:27 AM
#6
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|