2014-07-18 31 views
2

我不熟悉.NET编码。需要弄清楚如何使用DeepZoomTools.dll创建DZI

但是,我必须在共享服务器上创建DZI切片图像资源,并被告知可以实例化并使用DeepZoomTools.dll。

有人可以告诉我一个非常简单的DZI创建脚本,演示正确的.NET编码技术吗?我敢肯定,我可以根据需要进行修饰,但不知道从哪里开始。

假设我有一个jpg,脚本如何简单地将它切片并保存起来?

我可以想象它只有几行代码。服务器正在运行IIS 7.5。

如果有人有一个简单的例子,我会非常感激。

感谢

回答

0

实施例。 在这里,“clsCanvas”对象和集合几乎可以忽略,它是我的代码内部的一个对象,它使用GDI +生成图像,然后将它们放在磁盘上。下面的代码只是展示了如何从文件中获取一堆图像并将它们组装成一个可缩放的集合。希望这可以帮助某人:-)。

CollectionCreator cc = new CollectionCreator(); 

      // set default values that make sense for conversion options 
      cc.ServerFormat = ServerFormats.Default; 
      cc.TileFormat = ImageFormat.Jpg; 
      cc.TileSize = 256; 
      cc.ImageQuality = 0.92; 
      cc.TileOverlap = 0; 

      // the max level should always correspond to the log base 2 of the tilesize, unless otherwise specified 
      cc.MaxLevel = (int)Math.Log(cc.TileSize, 2); 

      List<Microsoft.DeepZoomTools.Image> aoImages = new List<Microsoft.DeepZoomTools.Image>(); 

      double fLeftShift = 0; 
      foreach (clsCanvas oCanvas in aoCanvases) 
      { 

       //viewport width as a function of this canvas, so the width of this canvas is 1 
       double fThisImgWidth = oCanvas.MyImageWidth - 1; //the -1 creates a 1px overlap, hides the seam between images. 
       double fTotalViewportWidth = fTotalImageWidth/fThisImgWidth; 
       double fMyLeftEdgeInViewportUnits = -fLeftShift/fThisImgWidth; ; //please don't ask me why this is a negative numeber 
       double fMyTopInViewportUnits = -fTotalViewportWidth * 0.3; 
       fLeftShift += fThisImgWidth; 

       Microsoft.DeepZoomTools.Image oImg = new Microsoft.DeepZoomTools.Image(oCanvas.MyFileName.Replace("_Out_Tile","")); 
       oImg.ViewportWidth = fTotalViewportWidth; 
       oImg.ViewportOrigin = new System.Windows.Point(fMyLeftEdgeInViewportUnits, fMyTopInViewportUnits); 

       aoImages.Add(oImg); 
      } 

      // create a list of all the images to include in the collection 
      cc.Create(aoImages, sMasterOutFile); 
相关问题