General discussion

Locked

"Invalid Parameter Used" Error

By Soundbomber ·
I am trying to read images from a SQL database by utilising the memorystream class. However, whenever I try to create a Bitmap object from the stream I get the above error. The database records are generally created from .bmp files and the byte object (b) and the stream (ms) are being created no problems. I have a feeling it has something to do with the bitmap header? I have tried various offsets (78 seems popular on posts) but to no avail. Here is my code:

b = CType(oPicture, Byte())
'Open a stream and read in the Image
Dim ms As New System.IO.MemoryStream(b)
ms.Read(b, iOffset, b.Length - iOffset)
'Create Bitmap from Stream
bm = New Bitmap(ms) *Error occurs here*

Can anyone offer any suggestions?

Thanks in advance

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by john.a.wills In reply to "Invalid Parameter Used" ...

look up the use of "New". I am not very good at objects, but it looks to me as though you should first Dim bm as Bitmap then assign.

Collapse -

by Soundbomber In reply to

Poster rated this answer.

Collapse -

by Soundbomber In reply to "Invalid Parameter Used" ...

Thats the correct use of bitmap object

Collapse -

by Soundbomber In reply to "Invalid Parameter Used" ...

Havent shown all the code. Dimmed the bm object earlier on.

Collapse -

by ravichandra_bdn In reply to "Invalid Parameter Used" ...

that memeory stream and byte stream should be
placed to picturebox control.

for this if u did not get mail me,another code
is their ,i will forward to u.

ravichandra_tnk@yahoo.co.in

Back to Web Development Forum
5 total posts (Page 1 of 1)  

Related Discussions

Related Forums