Select to view content in your preferred language

[ArcGIS SDK for .Net 100.x] PictureMarkerSymbol created on the fly...

915
1
Jump to solution
01-11-2018 04:24 AM
DamienPONNELLE
Emerging Contributor

Hello,

I start porting an application developed in v10.2.7 to v100.2 and the operation is not done without some difficulties.

There, I just discovered that the use of PictureMarkerSymbol from an image created on the fly no longer works if we use a BMP bitmap (no error but PictureMarkerSymbol does not appear on the map) but I have solved the problem using a PNG instead.

Example:

System.Drawing.Bitmap bm = new System.Drawing.Bitmap(100, 50);


System.Drawing.Graphics gra = System.Drawing.Graphics.FromImage(bm);
gra.FillRectangle(System.Drawing.Brushes.Orange, 0, 0, bm.Width / 2, bm.Height);
gra.FillRectangle(System.Drawing.Brushes.Magenta, bm.Width / 2, 0, bm.Width / 2, bm.Height);
var s = gra.MeasureString("Test", new System.Drawing.Font("Tahoma", 24, System.Drawing.FontStyle.Bold));
gra.DrawString("Test", new System.Drawing.Font("Tahoma", 24, System.Drawing.FontStyle.Bold), System.Drawing.Brushes.White, (bm.Width - s.Width) / 2, (bm.Height - s.Height) / 2);
gra.Flush();

MemoryStream ms = new MemoryStream();
bm.Save(ms, System.Drawing.Imaging.ImageFormat.Png); // ImageFormat.Bmp does not work with SDK 100.2!

PictureMarkerSymbol pms = new PictureMarkerSymbol(RuntimeImage.FromStreamAsync(ms).Result);

TestLayer.Graphics.Add(new Graphic(new MapPoint(2.3, 48.9, SpatialReferences.Wgs84), pms));

In the same way, if the creation of the bitmap was carried out using a BmpBitmapEncoder, it must be replaced by a PngBitmapEncoder (for example).

This looks like a bug, no? Or the BMP is no longer supported and in this case it would be wise to remove it from uses related to bitmaps ...

Regards,

damien.

0 Kudos
1 Solution

Accepted Solutions
dotMorten_esri
Esri Notable Contributor

Correct. BMP isn't supported.

View solution in original post

0 Kudos
1 Reply
dotMorten_esri
Esri Notable Contributor

Correct. BMP isn't supported.

0 Kudos