sorry for this question but i don't know how to correspond this: picture box1=blob1,picture box2=blob2,...etc;
i try it i look all the source code and didn't find how to take the image of each blob.where can i find the image of each blob? i have stuck.

basically i want to redesign each blob and put them in different picture boxes

Recommended Answers

All 3 Replies

To convert your byte[] to an image:

public static Image ByteArrayToImage(byte[] buffer)
        {
            using (MemoryStream ms = new MemoryStream(buffer))
            {
                System.Drawing.Image img = System.Drawing.Image.FromStream(ms);
                return img;
            }
        }

or if cannot use Image.FromStream method (no CF support):

public static Image byteArrayToImage(byte[] byteArrayIn)
        {
            // Write the byte array to the memory stream
            MemoryStream ms = new MemoryStream(byteArrayIn);

            // Create a new bitmap object from the memory stream
            Bitmap bmp = new Bitmap(ms);

            // Finally, return the bitmap
            return bmp;
        }

then, assign it: pictureBox1.Image = ByteArrayToImage(blob1);

what is the memorystream ?

what is the memorystream ?

It is a class that allocates a storage area (unsigned byte array) in memory (RAM) that can be acted upon by I/O classes expecting a Stream during construction/initialization. Because bitmaps/images are generally associated with files, classes that manipulate/operate on them contain methods that expect a Stream (such as FileStream), so to access those methods we converted the byte array to a MemoryStream. Refer to MemoryStream class and System.IO Namespace for further information regarding streams.

commented: Clear and concise reply. Great work as always :) +1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.