Hi Chris,
It will still work, the Bitmap object can handle jpegs. The following code
loads a jpeg into a byte array and displays it...
Image im = null;
private void Form1_Load(object sender, System.EventArgs e)
{
String fullAppName = Assembly.GetExecutingAssembly().GetName().CodeBase;
String fullAppPath = Path.GetDirectoryName(fullAppName);
String testImageName = Path.Combine(fullAppPath, "test.jpg");
FileStream fs = null;
MemoryStream ms = null;
try
{
if (File.Exists(testImageName))
{
fs = new FileStream(testImageName, FileMode.Open);
byte[] bytes = new byte[fs.Length];
fs.Read(bytes, 0, (int)fs.Length);
ms = new MemoryStream(bytes);
im = new Bitmap(ms);
}
}
finally
{
if (fs != null)
fs.Close();
if (ms != null)
ms.Close();
}
}
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.DrawImage(im, 0, 0);
base.OnPaint (e);
}
Geoff,
This will work if the data in the stream is a bitmap
image, but what if we're trying to construct a jpeg?
-----Original Message-----
Hi Brent,
You should be able to create a stream from the byte array and use the
overloaded constructor of the Bitmap class...
byte[] bytes = new byte[2048];
System.IO.MemoryStream ms = new System.IO.MemoryStream (bytes);
Image im = new Bitmap(ms);
--
Geoff Schwab
Program Manager
Excell Data Corporation
http://msdn.com/mobility
http://msdn.microsoft.com/mobility/prodtechinfo/devtools/n etcf/FAQ/default.aspx
This posting is provided "AS IS" with no warranties, and confers no rights.
Brent Yax said:
Does anyone know if there are any plans to include the
system.io MemoryStream or the System.Drawing
Image.fromstream functionality to .Net compact framework ?
Or does anyone know of a way in the .net cvompact
framework to display an image in a compact application
from a string or byte array ?
Thank you !!
.