473,395 Members | 1,554 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Metafile serialization impossible ?

Hi,

I would like to serialize a class which includes an image property field. I
have no problem saving with bitmap image. However, when using a metafile
(*.emf format) the result is also converted to a bitmap. Could someone please
point me in the right direction ?

Thanks,
Sylvain

[XmlElement("Image")]
public byte[] ImageByteArray
{
get
{

if (_image != null)
{
TypeConverter imageConverter = TypeDescriptor.GetConverter(_image.GetType());
return (byte[])imageConverter.ConvertTo(_image, typeof(byte[]));
}
else return null;

}

set
{

if (value != null)
{
//TypeConverter imageConverter = TypeDescriptor.GetConverter(typeof(Image));
//_image.GetType());
//_image = (Image)imageConverter.ConvertFrom((byte[])value);

using (MemoryStream stream = new MemoryStream(value))
{
_image = Image.FromStream(stream);
}
}
else _image = null;
}

}

Feb 12 '07 #1
0 1261

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Julian Ziersch | last post by:
This code causes a severe memory leak - the critical part is the call to GetHenhmetafile(). System.Drawing.Imaging.Metafile lImage = new System.Drawing.Imaging.Metafile("C:\\meta0.emf"); IntPtr...
1
by: sendhil | last post by:
hi, Iam doing some graphics programming with C#. I have to create a Windows MetaFile from a base64 encoded string. How do i create the file. I want to Overlay this Windows MetaFile on a image...
3
by: Richard Skopal | last post by:
In .NET Windows forms I can create a metafile using this code: Graphics grph = aControl.CreateGraphics(); IntPtr ipHDC = grph.GetHdc(); Metafile mf = new Metafile(aImgFilePath, ipHDC,...
2
by: George Yefchak | last post by:
Hi I need to retrieve a metafile image from the clipboard and render it as a bitmap in my application. In particular, an image will be placed on the clipboard by pasting from PowerPoint (I...
0
by: weiruic | last post by:
I am trying to create a metafile (.emf) on the harddisk, write graphics from a graphics object to it, and then save it. I can do this successfully except I cannot set the horizontal and vertical...
2
by: NickP | last post by:
Hi there, I am obtaining a meta file from the clipboard via the following code Dim CF_ENHMETAFILE As Integer = 14 Dim cMFeImage As Imaging.Metafile Dim pIPrClipboard As IntPtr =...
2
by: Laurent Navarro | last post by:
Hello, I am using a library which returns a byte containing RAW data, ie all pixels' color values coded in a byte array without header. I would like to save those data into a JPEG file so I...
2
by: Alexander Gorbylev | last post by:
Hi! Let the size of vector is e.g. 3.5". I render the same vector on a printer & a screen on the same procedure: printDoc_BeginPrint(object sender, PrintEventArgs e) { .... vector.Width *...
1
by: bern11 | last post by:
I can get bitmaps from the clipboard, but how do I get Metafiles? The specific instance I am testing is copying a piece of Word clip-art into the clipboard and trying to read it in an application. ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.