Results 1 to 5 of 5

Thread: Pixel Plotting with a Pointer - Problem [RESOLVED]

  1. #1

    Thread Starter
    Junior Member ISDP's Avatar
    Join Date
    Mar 2002
    Posts
    28

    Question Pixel Plotting with a Pointer - Problem [RESOLVED]

    Hi,

    After reading this thread: http://www.vbforums.com/showthread.p...hreadid=209455 I found a link to the following site, which describes how to use a pointer as the fastest way to plot single pixels: http://rookscape.com/vbgaming/tutAY.php , but I'm having some problems with it.

    At the beginning it declares the variable 'sa' as a 'SAFEARRAY2D' to store the image's data in, but when the data has been assigned and the CopyMemory function is used, with the variable 'sa' as the source of the data, I get the following warning:

    Compile Error:

    Type mismatch: array or user-defined type expected

    If anyone could take a look at the code in the link and see why it might be doing this I would be very greatful,

    Thanks,

    ISDP
    Last edited by ISDP; Dec 22nd, 2002 at 05:47 AM.
    "Mmm, so I hear they have the internet on computers these days..."

  2. #2
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    i've had the same problem with that code...
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  3. #3
    Addicted Member
    Join Date
    Aug 2002
    Location
    Baltimore, MD
    Posts
    230
    I think he forgot some steps. Try the example here instead - http://www.allapi.net/apilist/GetObject.shtml

  4. #4
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    You need to declare two versions of the API:
    VB Code:
    1. Private Declare Function VarPtrArray Lib "msvbvm50.dll" Alias "VarPtr" (Ptr() As Any) As Long
    2. Private Declare Function VarPtr Lib "msvbvm50.dll" (Ptr As Any) As Long
    He only put one of the in, its the same API except one takes a Array and the other doesn't. Use:
    VB Code:
    1. CopyMemory ByVal VarPtrArray(pic), VarPtr(sa), 4
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  5. #5

    Thread Starter
    Junior Member ISDP's Avatar
    Join Date
    Mar 2002
    Posts
    28
    Ok, thanks for all the help, it's been very useful! I'll get back to you all if I have any more problems,

    ISDP
    "Mmm, so I hear they have the internet on computers these days..."

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