|
-
Aug 5th, 2008, 06:14 AM
#1
Thread Starter
KING BODWAD XXI
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.
-
Aug 6th, 2008, 03:02 PM
#2
Re: Directly Manipulate the IMAGE property
As far as I understand an objects Image is a wrapper for a GDI DDB (Device Dependent Bitmap). An objects Picture is a wrapper for a GDI DIB (Device Independant Bitmap).
DIBs are owned by the system so you can mess with them directly using a safearray hack. DDBs are owned by the device and can't be messed with directly. GDI functions can work with either. DDBs are faster than DIBs.
Edit:
Code:
Dim OBmp As IPictureDisp
Set OBmp = Object.Image
'or
Object.Picture = Object.Image
Last edited by Milk; Aug 6th, 2008 at 04:48 PM.
Reason: tried to answer the question this time.
-
Aug 7th, 2008, 01:59 AM
#3
Thread Starter
KING BODWAD XXI
Re: Directly Manipulate the IMAGE property
Oh cool thanks that info is really helpful, its a nightmare trying to find anything out about the image property. Its structure etc is a mystery
I have found a method using the SetDIBits and GetDIBits API. These are used on a bitmap created in the API that has the image Blt'ed to it. I will post the code once I manage to finalise it
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|