Print Task ?mage

1725
1
12-30-2013 09:55 PM
by Anonymous User
Not applicable
Original User: selcuktinaz

Hi,

I am using Silverlight 3.0 Api for sl. In my application i am using PrinTask. Map that is given to map, has 2 layer.
1-FeatureLayer => that has initialized,updated, and has only one graphic inside.
2-GraphicLayer >= that has 4 MapPoint graphic with TextSymbol

map does not have any other thing.
I also made map's background Transparent.
I set feature Layer renderer property as SimpleRenderer that fill property = transparent.
I did it for GraphicLayer too.

Here is my problem. Despite of all these settings, Picture that i received from PrintTask does not have transparent background.
I set PrintTask Format parameter as GIF or PNG32. But no solution. I add handled and wanted images to attachement

Thanks in Advance.
0 Kudos
1 Reply
by Anonymous User
Not applicable
Original User: doopsterus

In my experience of using the print task I have not been able to get back an image that has a transparent background no matter what format I specify.  Here are two things you can try.


  1. For your case you show here it might be worth looking into the ImageTools library to see if you can remove white background from your print.


  2. You can generate the image on the client side.  I've done this on a much larger scale than what you are wanting to do, however, here is the trick to that. 


    1. Upgrade to SL5.

    2. All of the images need to be coming from the same domain as the application otherwise you can't access the image pixels.  You need to use a proxy like provide in this sample.

    3. Create a childwindow with a viewbox which contains a new map control in it with the specified data and proportion to the final image size you want print.

    4. Use the WritableBitmap and ImageTools to print the image to the correct image type and/or save it.  Here is some sample code below I threw together.  It might work.  Using this method I am able to create

    5. var dpi = 192;
      var image = new WriteableBitmap(YOUR_NEW_MAP_CONTROL, new System.Windows.Media.ScaleTransform { ScaleX = dpi / 96, ScaleY = dpi / 96 });
      var ms = new MemoryStream();
      
      var encoder = new PngEncoder();
      var img = ImageExtensions.ToImage(image);
      encoder.Encode(img, ms);
      
      var bytes = ms.ToArray();
      using (var stream = sfd.OpenFile())
      {
         stream.Write(bytes, 0, bytes.Length);
         stream.Close();
      }
      



Hope this helps.  Thanks!
0 Kudos