Results 1 to 4 of 4

Thread: Pixel array -----> Picturebox (wow, pset is slow)

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2001
    Posts
    2

    Question

    What is the most compact and simple way to take a 50x50 array of color values and blit that into a 50x50 picturebox. Sorry if you've heard this one before.

    - // /\/\atrix // -

  2. #2
    Fanatic Member
    Join Date
    Sep 1999
    Location
    Bethel, North Carolina, USA
    Posts
    987
    The SetPixelV would probably be the fastest way to draw directly to the picturebox. If this isn't fast enough you can draw directly to an offscreen DC and then just blt it directly from memory into the picture box (alot more code), let me know if you need an example for that....

    Code:
    Private Declare Function SetPixelV Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
    
    
    Private Sub Form_Load()
     Dim iX As Integer
     Dim iY As Integer
     Dim lColorArray(0 To 50, 0 To 50)
     ' resize picture box to 50 X 50 pixels
     Picture1.Height = 50 * Screen.TwipsPerPixelX
     Picture1.Width = 50 * Screen.TwipsPerPixelY
     
     Picture1.AutoRedraw = True
     
     ' fill the array with random colors
     For iX = 0 To 50
        For iY = 0 To 50
            lColorArray(iX, iY) = RGB(Rnd * 255, Rnd * 255, Rnd * 255)
        Next iY
     Next iX
     
     ' set the pixel's color
     For iX = 0 To 50
        For iY = 0 To 50
            SetPixelV Picture1.hdc, iX, iY, lColorArray(iX, iY)
        Next iY
     Next iX
        
    End Sub
    {Insert random techno-babble here}

    {Insert quote from some long gone mofo here}

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2001
    Posts
    2

    Talking Worked like a charm

    Thank you! That worked wonderfully.

  4. #4
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    However, YoungBuck, I would code for that...

    So far i'm getting a frame every 9 secs for a 640x480 picture w/ get & setpixelV
    (but i'll be using DDraw soon)
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

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