|
-
Apr 22nd, 2002, 08:01 AM
#1
Thread Starter
New Member
creating a picture through memorystream
hi all!
other question... how can i create a picture from a memorystream?
i.e. my memorystream contains the data for the image.fromstream property. the memorystream is writen like
file = rs("picture").Value 'dim file() as byte
memoryStream.Write(file, 0, file.Length) ' Dim memoryStream As New IO.MemoryStream()
ok, now i am loading my picture control like
memoryStream.Position = 0
PictureBox1.Image.FromStream(memoryStream)
and that doesnt work. i get always a message "invalid parameter"
what is there wrong??
PLEASE give me any suggestions you have...thx a lot
Last edited by PJ6; Apr 24th, 2002 at 08:36 AM.
-
Apr 24th, 2002, 08:38 AM
#2
Thread Starter
New Member
Is there really no person who migth know the answer?
-
Nov 20th, 2002, 02:55 AM
#3
Addicted Member
Here is a command button that loads a Bitmap from a file, coverts it into an Array of Bytes, converts the Bytes into a memory stream, and then converts the memory stream into an image.
Seems to work. Does this help? The question I have now is how to you draw one bitmap and then extract multiple bitmaps from that.
I.E. have one FileStream that connects to one large bitmap, covert it to bytes, and then extract the bytes of individual images within the image, and produce smaller image streams from that. Anyone have any code for that?
Code:
Private Sub cmdDraw_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDraw.Click
Dim oStream As New IO.FileStream(Windows.Forms.Application.StartupPath & "\" & "space.bmp", IO.FileMode.Open)
Dim bByte() As Byte
ReDim bByte(oStream.Length)
oStream.Read(bByte, 1, UBound(bByte))
oStream.Close()
oStream = Nothing
Dim oMem As New IO.MemoryStream(bByte, 1, UBound(bByte))
Dim oImage As Image
oImage = System.Drawing.Image.FromStream(oMem)
Me.BackgroundImage = oImage
End Sub
-Daryl
"Two More Rolls of Duct tape, and the world is mine!"
VB.NET Guru
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
|