Results 1 to 3 of 3

Thread: creating a picture through memorystream

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2002
    Posts
    13

    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.

  2. #2

    Thread Starter
    New Member
    Join Date
    Mar 2002
    Posts
    13
    Is there really no person who migth know the answer?

  3. #3
    Addicted Member Dmyze's Avatar
    Join Date
    Mar 2002
    Location
    Seattle
    Posts
    160
    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
  •  



Click Here to Expand Forum to Full Width