2014-07-18 65 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); 
相關問題