Results 1 to 3 of 3

Thread: Directly Manipulate the IMAGE property

Threaded View

  1. #1

    Thread Starter
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176

    Directly Manipulate the IMAGE property

    Well my brain is fried so I hope I can write a post that makes sense...if not I am sorry

    I am trying to create a fast pixel change function that changes the IMAGE property on a picturebox. The function I have only changes the PICTURE property and the code is below;

    Code:
    Public Sub GetBitmapImageData(PB As PictureBox)
    Dim Pic() As Byte
    Dim sa As SAFEARRAY2D
    Dim bmp As BITMAP
    Dim StartArrayLeft As Long
    Dim StartArrayTop As Long
    Dim x As Long
    Dim y As Long
    Dim Pos As Long
    Dim NewImage As Long
    
        
        
        'Copy The Image
        GetObjectAPI PB.Picture, Len(bmp), bmp
        
        'Create Some storage space of the right size
        With sa
            .cbElements = 1
            .cDims = 2
            .Bounds(0).lLbound = 0
            .Bounds(0).cElements = bmp.bmHeight
            .Bounds(1).lLbound = 0
            .Bounds(1).cElements = bmp.bmWidthBytes
            .pvData = bmp.bmBits
        End With
        
        'Now get the data
        CopyMemory ByVal VarPtrArray(Pic), VarPtr(sa), 4
      
        'Now Grab Up until the end
        ReDim ImagePixelData(bmp.bmHeight, bmp.bmWidth)
        
        For y = 0 To bmp.bmHeight - 1 'To 0 Step -1
            'Initialise Pos
            Pos = 0
            For x = 0 To bmp.bmWidth - 1
                ImagePixelData(bmp.bmHeight - y, x).B = Pic(Pos, y)
                ImagePixelData(bmp.bmHeight - y, x).G = Pic(Pos + 1, y)
                ImagePixelData(bmp.bmHeight - y, x).R = Pic(Pos + 2, y)
                
                Randomize
                Pic(Pos, y) = Rnd * 255
                
                'Increment to next pixel
                Pos = Pos + 3
            Next x
        Next y
        
        'Delete Array to clear it
        CopyMemory ByVal VarPtrArray(Pic), 0&, 4
    
        
    End Sub
    Does anyone know how I can convert this manipulate the image field instead of the picture field? It appears that the image field is not a bitmap style format. I cant actually find what type or format its in. If I could get the raw data from the image field then I would be able to make adjustments.

    Failing that does anyone know how to convert the image property into the picture property?

    I hope this post makes some sort of sense, I really cant think straight after trying all sorts of API stuff.
    Last edited by BodwadUK; Aug 5th, 2008 at 06:18 AM.
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

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