PictureMarkerSymbol


ピクチャマーカーの速度差
透過ならpng / 非透過ならJpegかな…。emfは試してないがHelpによると速いらしいが…。
ArcGIS 10.2

002.bmp,229
002.gif,1189
002.jpg,168
002.png,284

むしろ軽いイメージのGIFを使うと駄目と言う事か。

ly asm = Assembly.GetExecutingAssembly();
  string dirBase = System.IO.Path.GetDirectoryName(asm.Location);

  string imgDir = System.IO.Path.Combine(dirBase, "img");
  var files = System.IO.Directory.GetFiles(imgDir);

  using (ComReleaser com = new ComReleaser())
  {
    var env = this.axMapControl1.ActiveView.Extent;
    IScreenDisplay scDisplay = this.axMapControl1.ActiveView.ScreenDisplay;
    scDisplay.StartDrawing(scDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
    try
    {
      IPoint pt = new PointClass();
      com.ManageLifetime(pt);

      pt.PutCoords(env.XMin + env.Width / 2, env.YMin + env.Height / 2);

      foreach (var file in files)
      {
        Stopwatch spWatch = new Stopwatch();
        spWatch.Start();

        string fname = System.IO.Path.GetFileName(file);

        var sym = this.getPictSymbol(file);

        sym.SetupDC(scDisplay.hDC, scDisplay.DisplayTransformation);

        for (int i = 0; i < 1000; i++)
        {
          sym.Draw((IGeometry)pt);
        }

        sym.ResetDC();

        spWatch.Stop();
        Debug.Print("{0},{1}", fname, spWatch.ElapsedMilliseconds);
      }//end loop


    }
    finally
    {
      scDisplay.FinishDrawing();
    }
  }//end com
}//end method

private ISymbol getPictSymbol(string fileName)
{
  esriIPictureType type = esriIPictureType.esriIPictureBitmap;

  string ext = System.IO.Path.GetExtension(fileName).ToLower();
  switch (ext)
  {
    case ".jpg":
    case ".jpeg":
      type = esriIPictureType.esriIPictureJPG;
      break;
    case ".png":
      type = esriIPictureType.esriIPicturePNG;
      break;
    case ".emf":
      type = esriIPictureType.esriIPictureEMF;
      break;
    case ".gif":
      type = esriIPictureType.esriIPictureGIF;
      break;
    default:
      break;
  }//end switch

  IPictureMarkerSymbol pictSymbol = new PictureMarkerSymbolClass();
  pictSymbol.CreateMarkerSymbolFromFile(type, fileName);

  return (ISymbol)pictSymbol;
}//end method
カテゴリー: 開発 タグ: , パーマリンク