Results 1 to 5 of 5

Thread: surface properties

  1. #1
    sunnyl
    Guest

    Unhappy surface properties

    I use the following code to create a surface from a file:

    Code:
    Public imgDesc As DDSURFACEDESC2  'image surface description
    
    'in a sub
    imgDesc.lFlags = DDSD_CAPS 
    imgDesc.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN
    Set imgBuffer = DDraw.CreateSurfaceFromFile(FileName, imgDesc)
    
    'change the size of the picture box so it is the same size as the picture
    picMain.Width = picMain.ScaleX(imgDesc.lWidth, vbPixels, vbTwips)
    picMain.Height = picMain.ScaleY(imgDesc.lHeight, vbPixels, vbTwips)
    
    'then the blitting is done
    The code works fine the first time round. However when I run it the second time in the life time of the program (with a different file), the dimensions of imgDesc (lwidth and lheight) don't seem to change at all...they remain in the same dimensions as the first picture loaded. I'm probably missing something to reset the surface or something similar, but I have no idea what it is!

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    imgdesc should be nulled before next use, simplest would be to declare it procedure scope in the sub where the surface is loaded.
    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.

  3. #3
    sunnyl
    Guest
    Do you mean just imgDesc = Null?

    I'm getting this when it runs:
    Only UDTs defined in public object modules can be coerced to or from a variant or passed to late-bound functions
    If it means anything, the code I use is in a class module. Declaring it in one procedure isn't really an option in my case.

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    No i meant that you should have a blank UDT, all values 0 that is. You can do this by declaring an unused ddsurfacedesc2 and assign imgDesc it.
    Null is a value you can only assign variants.
    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
    sunnyl
    Guest
    cool stuff, thanks kedaman!

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