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;
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.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
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.![]()




Reply With Quote