Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Manipulating PictureData Property

Status
Not open for further replies.

Frink

Programmer
Mar 16, 2001
798
GB
Hallo,

This is a bit of a knotty one, but I really would like to get it to work.

I want to write to the PictureData property of an image control on a form, but it seems to be read only.

I have written two routines to read/write a byte of data:
Code:
Public Sub WriteByte(pvarBitmap, ByVal plngByteOffset As Long, ByVal pbytValue As Byte)
  pvarBitmap(plngByteOffset) = pbytValue
End Sub
Public Function bytReadByte(pvarBitmap, ByVal plngByteOffset As Long) As Byte
  bytReadByte = pvarBitmap(plngByteOffset)
End Function

I have written a test harness to try it out using an array of bytes and the PictureData property of an image control:
Code:
  Dim bytArray(0 To 99) As Byte
  MsgBox bytReadByte(Me!imgImage1.PictureData, 0) & " " & bytReadByte(bytArray, 0)
  WriteByte Me!imgImage1.PictureData, 0, 39
  WriteByte bytArray, 0, 39
  MsgBox bytReadByte(Me!imgImage1.PictureData, 0) & " " & bytReadByte(bytArray, 0)

As you can see, this outputs byte 0 of the PictureData and the byte array.
Then it attempts to set byte 0 of the PictureData and the byte array.
Lastly it re-outputs the same bytes as before which I would expect to have the changed values.

Unfortunately, while the byte array code works, the PictureData one doesn't.

I can copy the PictureData into a byte array, change it and copy the byte array back and the PictureData is updated.

Any ideas why the PictureData is sometimes read-only?

- Frink
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top