Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Storing images in memory

Status
Not open for further replies.

fugigoose

Programmer
Jun 20, 2001
241
US
How would I load several bitmaps from file and store them in an array? What type of array would it be? I need to be able to bitblt them onto my form as i need to. I tried using an stdPicture array, but bitblt won't copy them.
 
Dim pic(5) As StdPicture

Set pic(0)= LoadPicture("C:\SomePicture.Bmp")
 
If you are using an array of StdPicture objects, then BitBlt won't work as it accepts two hDC arguments, both for source and destination.

You should use the [tt]PaintPicture[/tt] method of the form instead, which accepts a picture object as the argument and performs the BitBlt operation (infact the StretchBlt operation) on the form.
 
If you really want to use bitblt, then IPicture is probably the easiest starting point out of the the three. eg:
[tt]
Dim wombat As IPicture
Dim hDC As Long

Set wombat = LoadPicture("c:\demo.bmp")
wombat.SelectPicture Form1.hDC, hDC, 0& ' just gives wombat an hDC. Form needs to be autoredraw to stop VB eating the picture...
BitBlt Picture1.hDC, 0, 0, 100, 100, wombat.CurDC, -10, -10, SRCCOPY
 


Sorry, I was thinking of something simplier/different (below) and only read the first sentence:
[blue]
Code:
    Dim pic(5) As StdPicture
    Dim iOrigScaleMode  As Integer
    Me.AutoRedraw = True

    iOrigScaleMode = Me.ScaleMode
    Me.ScaleMode = vbPixels
    Set pic(0) = LoadPicture("H:\Graphics\MyPict.bmp")

    pic(0).Render Me.hdc, 0, 0, Me.ScaleWidth, Me.ScaleHeight, 0, pic(0).Height, pic(0).Width, -pic(0).Height, 0
    
    Me.ScaleMode = iOrigScaleMode
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top