PC Review


Reply
Thread Tools Rate Thread

C# storing images within an array

 
 
ryan
Guest
Posts: n/a
 
      9th Jul 2011
Hi,
My name is Ryan. I'm learning C# .Net using Visual Studio Express 2010, running on Windows 7. I would like to learn more on how to store an image to byte format within an array.

My question: Looking at the code reference below, how do I change (stream, System.Drawing.Imaging.ImageFormat.Png); to something that would have a direct reference to an image within a file? What are my alternative approaches?

Code sample:

public static byte[] ImageToByte2(Image img)
{
byte[] byteArray = new byte[0];
using (MemoryStream stream = new MemoryStream())
{
img.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
stream.Close();

byteArray = stream.ToArray();
}
return byteArray;
}
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: C# storing images within an array Ryan Microsoft C# .NET 1 10th Jul 2011 04:23 PM
Re: C# storing images within an array Ryan Microsoft C# .NET 0 9th Jul 2011 11:14 PM
User Images: Storing in Files VS Storing in Database Jonathan Wood Microsoft ASP .NET 1 2nd Jun 2008 06:56 PM
Redimming an array dynamically assigned from range (how to redim first dimension of a 2-D array? /or/ reverse the original array order) Keith R Microsoft Excel Programming 3 13th Nov 2007 05:08 PM
meaning of : IF(Switch; Average(array A, array B); array A) =?Utf-8?B?RFhBVA==?= Microsoft Excel Worksheet Functions 1 24th Oct 2006 06:11 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:56 AM.