Results 1 to 7 of 7

Thread: byte array to bitmap and back?

  1. #1

    Thread Starter
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267

    Question byte array to bitmap and back?

    Anyone know how to convert back and forth between a System.Drawing.Bitmap and a byte[]?
    Last edited by Magiaus; May 24th, 2004 at 09:26 AM.
    Magiaus

    If I helped give me some points.

  2. #2
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    hmmmmm
    what do you mean by that? you want the color values in a bitmap? or what
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  3. #3

    Thread Starter
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267
    I want the actual bytes of the file but I don't want to write a file
    Magiaus

    If I helped give me some points.

  4. #4
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    have you tried the MemoryStream class ( in System.IO ) , eg:
    PHP Code:
                Bitmap bmp=new Bitmap(300 300);
                
    Graphics grp Graphics.FromImage(bmp);
                
    Pen pn = new Pen(new SolidBrush(Color.BlueViolet),(float)5);
                
    grp.DrawRectanglepn 10 10 100 100 );
                
    grp.DrawString("test 123" this.Font , new SolidBrush(Color.Red),new RectangleF(12 12 200,200));
                
    System.IO.MemoryStream ByteStream = new System.IO.MemoryStream();
                
    bmp.Save(ByteStream System.Drawing.Imaging.ImageFormat.Bmp);
                
    byte[] bytes ByteStream.ToArray(); // put the Bitmap into a byte array.
                
    ByteStream.Close();
                
    bmp.Dispose(); 
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  5. #5

    Thread Starter
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267
    So I can just Save to a stream that way eh..? cool.
    Magiaus

    If I helped give me some points.

  6. #6
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    hmm very interesting... could you tell me what use do you have for that though?
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  7. #7

    Thread Starter
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267
    I have picture that are uploaded to a website. The binary info is then put in SQLServer. I need to be able to get a bitmap incase I want to edit it or something later. Plus, my code runs a web optimize on the graphics an converts them all to jpeg. This can be done at any time by admin. Full resize and so on to save space in SQL Server. Well, it did before my resize calculation blew up today. I hate 0.
    Magiaus

    If I helped give me some points.

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