Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Windos
win32.3rdparty
win32.directx.audio
win32.directx.ddk
win32.directx.graphics
win32.directx.input
win32.directx.managed
win32.directx.misc
win32.directx.networking
win32.directx.sdk
win32.directx.video
win32.dirx.grap.shaders
win32.gdi
win32.international
win32.kernel
win32.messaging
win32.mmedia
win32.networks
win32.ole
win32.rtc
win32.tapi
win32.tapi.beta
win32.tools
win32.ui
win32.wince
win32.wmi
windows.mediacenter
winfx.aero
winfx.announcements
winfx.avalon
winfx.collaboration
winfx.fundamentals
winfx.general
winfx.indigo
winfx.sdk
winfx.winfs
  
 
date: Thu, 29 Nov 2007 15:03:22 +0100,    group: microsoft.public.windows.developer.winfx.avalon        back       


Vector graphic image   
Hi there,

I would like to import a vector image (which is in a database, but this is
not my point) in a WPF application. I can find function to load bitmap image
but can't see no way to import svg/emf/eps... images. Is it a limitation of
WPF ?

Regards
date: Thu, 29 Nov 2007 15:03:22 +0100   author:   Oriane

Re: Vector graphic image   
Hello,

> I would like to import a vector image (which is in a database, but
> this is not my point) in a WPF application. I can find function to
> load bitmap image but can't see no way to import svg/emf/eps...
> images. Is it a limitation of WPF ?

Avalon can't be aware of all the possible vector formats … You'll have to 
use an utility to convert them into the vector XAML format first. After that, 
they could be loaded right away as vector images.

(H) Serge
date: Thu, 29 Nov 2007 14:52:23 +0000 (UTC)   author:   Serge Baltic

Re: Vector graphic image   
Hello Serge,
hello Srege,

"Serge Baltic"  wrote in 
news:dc0986bf7a1c28ca00c7bac58ccf@news.microsoft.com...
> Avalon can't be aware of all the possible vector formats … You'll have to 
> use an utility to convert them into the vector XAML format first. After 
> that, they could be loaded right away as vector images.
I'm a newbie and you answer is quite unclear to me.
First, what does "convert into the vector XAML format" mean ? Do you mean 
that Xaml code should be yield by the utility ?
Second, once this conversion has been done, how do you link the XAML code 
with that converted vector image ? My goal is to use that image into for 
example a hierarchical template:

<HierarchicalDataTemplate x:Key="tvTemplate" DataType="x:Type local:Element" 
ItemsSource="{Binding Path=SubElements}" >
      <DockPanel MouseRightButtonDown="DockPanel_MouseRightButtonDown" 
Width="Auto" >
        <Image x:Name="iconeTv" Source="{Binding Path=Icone}" />
        <TextBlock Text="{Binding Path=Name}"  />
      </DockPanel>
</HierarchicalDataTemplate>

In the third line (beginning with <Image), I would like to give my vector 
image as a source. I guess I have to use C# with a MemoryStream... What do 
you think ?

> (H) Serge
Thanks
date: Fri, 30 Nov 2007 10:36:58 +0100   author:   Oriane

Re: Vector graphic image   
Salut Oriane,

Oriane wrote:

> First, what does "convert into the vector XAML format" mean ? Do you 
> mean that Xaml code should be yield by the utility ?

Yes. See this thread for more info:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1225491&SiteID=1

Load the image you want to convert in the corresponding tool, and try 
and find a converter to XAML. The Illustrator-to-XAML converter is 
supposed to be very good, but I never tried it.

> Second, once this conversion has been done, how do you link the XAML 
> code with that converted vector image ? My goal is to use that image 
> into for example a hierarchical template:
> 
> <HierarchicalDataTemplate x:Key="tvTemplate" DataType="x:Type 
> local:Element" ItemsSource="{Binding Path=SubElements}" >
>      <DockPanel MouseRightButtonDown="DockPanel_MouseRightButtonDown" 
> Width="Auto" >
>        <Image x:Name="iconeTv" Source="{Binding Path=Icone}" />
>        <TextBlock Text="{Binding Path=Name}"  />
>      </DockPanel>
> </HierarchicalDataTemplate>
> 
> In the third line (beginning with <Image), I would like to give my 
> vector image as a source. I guess I have to use C# with a 
> MemoryStream... What do you think ?

No, once your image is converted to XAML, you can simply link to it. For 
example, put it into a ResourceDictionary, and link to it using a 
StaticResource markup extension.

Here is a super simple example:

   <Window.Resources>
     <ResourceDictionary>
       <ResourceDictionary.MergedDictionaries>
         <ResourceDictionary Source="Dictionary1.xaml" />
       </ResourceDictionary.MergedDictionaries>
     </ResourceDictionary>
   </Window.Resources>

   <Grid>
     <Image Source="{StaticResource MyImage}" />
   </Grid>


with (in Dictionary1.xaml)

<ResourceDictionary 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
   <DrawingImage x:Key="MyImage">
     <DrawingImage.Drawing>
       <DrawingGroup>
         <DrawingGroup.Children>
           <GeometryDrawing Brush="#FFFF0000"
                            Geometry="F1 M 110.889,144.583L 87,168L 
137.222,167.833L 110.889,144.583 Z ">
             <GeometryDrawing.Pen>
               <Pen LineJoin="Round"
                    Brush="#FF000000" />
             </GeometryDrawing.Pen>
           </GeometryDrawing>
         </DrawingGroup.Children>
       </DrawingGroup>
     </DrawingImage.Drawing>
   </DrawingImage>
</ResourceDictionary>

If you need to do this in code, you can too, but then you must use a 
XamlReader to load the ResourceDictionary, then add it to the Window's 
resources and then you can use the DrawingImage as if it had been added 
to the XAML directly.

HTH,
Laurent
-- 
Laurent Bugnion [MVP ASP.NET]
Software engineering, Blog: http://www.galasoft.ch
PhotoAlbum: http://www.galasoft.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
date: Fri, 30 Nov 2007 17:34:17 +0100   author:   Laurent Bugnion, MVP

Re: Vector graphic image   
Ok then. 

Thanks a lot !
date: Fri, 30 Nov 2007 17:59:00 +0100   author:   Oriane

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us