Example #1
0
        /// <summary>
        /// Call the build function of the inner Raster Type and generate a thumbnail from the Builder Item created.
        /// </summary>
        /// <param name="pItemURI">URI of the Item to be built</param>
        /// <returns></returns>
        public IBuilderItem Build(IItemURI pItemURI)
        {
            IBuilderItem pbuilderItem = innerRasterBuilder.Build(pItemURI); // Generate the IBuilderItem

            Resampling(pbuilderItem);                                       // Generate the Thumbnail from the item.
            return(pbuilderItem);
        }
Example #2
0
        /// <summary>
        /// Each BuilderItem contains a Function Raster Dataset which is used to create the thumbnail.
        /// The thumbnail is created by Nearest Neighbor resampling of the Function Raster Dataset.
        /// The resampled raster is exported as a byte array and saved Into the IMemoryBlobStreamVariant.
        /// The blob is then inserted into the Thumbnail field.
        /// </summary>
        /// <param name="mybuilderItem">Item containing the Function Dataset to be added to the Mosaic Dataset</param>
        private void Resampling(IBuilderItem mybuilderItem)
        {
            try
            {
                IFunctionRasterDataset pFuncRasterDataset = mybuilderItem.Dataset; // Get the FunctionRasterDataset from mybuilderItem
                IRasterDataset         pRasterDataset;
                pRasterDataset = (IRasterDataset)pFuncRasterDataset;               // Cast the FunctionRasterDataset to Raster Dataset
                IPropertySet thePropSet = pFuncRasterDataset.Properties;           // Get the properties of the raster Dataset
                IRaster      praster    = pRasterDataset.CreateDefaultRaster();    // Create default raster from the above raster dataset
                praster.ResampleMethod = rstResamplingTypes.RSP_NearestNeighbor;   // The raster is resampled by RSP_NearestNeighbor
                IRasterProps pRasterProps = (IRasterProps)praster;                 // Raster properties are used to update the height, width of the raster
                pRasterProps.Height = 256;
                pRasterProps.Width  = 256;

                IRasterExporter pConverter = new RasterExporterClass();                           // IRasterExporter object is used to convert the raster to byte array.
                byte[]          pBytesArr;
                pBytesArr = pConverter.ExportToBytes(praster, "TIFF");                            // Convert the resampled Raster to a Byte array
                IMemoryBlobStream        memBlobStream = new MemoryBlobStream();                  // Create new IMemoryBlobStream
                IMemoryBlobStreamVariant varBlobStream = (IMemoryBlobStreamVariant)memBlobStream; // Assign to IMemoryBlobStreamVariant
                object anObject = pBytesArr;
                varBlobStream.ImportFromVariant(anObject);                                        // IMemoryBlobStreamVariant object is assigned the byte array
                thePropSet.SetProperty("ThumbNail", memBlobStream);                               // and saved to the property "ThumbNail"
            }
            catch (Exception ex)
            {
                System.Exception myExc = new System.Exception(
                    "Error: Failed to Re-Sampled the raster.Thumbnails will not be created." + ex.Message, ex);
                throw myExc;
            }
            return;
        }
Example #3
0
 public IBuilder AddItem(IBuilderItem item)
 {
     if (this.House.Items == null)
     {
         this.House.Items = new List <IBuilderItem>();
     }
     this.House.Items.Add(item);
     return(this);
 }
        /// <summary>
        /// Each BuilderItem contains a Function Raster Dataset which is used to create the thumbnail.
        /// The thumbnail is created by Nearest Neighbor resampling of the Function Raster Dataset. 
        /// The resampled raster is exported as a byte array and saved Into the IMemoryBlobStreamVariant. 
        /// The blob is then inserted into the Thumbnail field.
        /// </summary>
        /// <param name="mybuilderItem">Item containing the Function Dataset to be added to the Mosaic Dataset</param>
        private void Resampling(IBuilderItem mybuilderItem)
        {
            try
            {
                IFunctionRasterDataset pFuncRasterDataset = mybuilderItem.Dataset; // Get the FunctionRasterDataset from mybuilderItem
                IRasterDataset pRasterDataset;
                pRasterDataset = (IRasterDataset)pFuncRasterDataset; // Cast the FunctionRasterDataset to Raster Dataset
                IPropertySet thePropSet = pFuncRasterDataset.Properties; // Get the properties of the raster Dataset
                IRaster praster = pRasterDataset.CreateDefaultRaster(); // Create default raster from the above raster dataset
                praster.ResampleMethod = rstResamplingTypes.RSP_NearestNeighbor; // The raster is resampled by RSP_NearestNeighbor
                IRasterProps pRasterProps = (IRasterProps)praster; // Raster properties are used to update the height, width of the raster
                pRasterProps.Height = 256;
                pRasterProps.Width = 256;

                IRasterExporter pConverter = new RasterExporterClass(); // IRasterExporter object is used to convert the raster to byte array.
                byte[] pBytesArr;
                pBytesArr = pConverter.ExportToBytes(praster, "TIFF"); // Convert the resampled Raster to a Byte array 
                IMemoryBlobStream memBlobStream = new MemoryBlobStream(); // Create new IMemoryBlobStream
                IMemoryBlobStreamVariant varBlobStream = (IMemoryBlobStreamVariant)memBlobStream; // Assign to IMemoryBlobStreamVariant
                object anObject = pBytesArr;
                varBlobStream.ImportFromVariant(anObject); // IMemoryBlobStreamVariant object is assigned the byte array
                thePropSet.SetProperty("ThumbNail", memBlobStream); // and saved to the property "ThumbNail"
            }
            catch (Exception ex)
            {
                System.Exception myExc = new System.Exception(
                    "Error: Failed to Re-Sampled the raster.Thumbnails will not be created." + ex.Message, ex);
                throw myExc;
            }
            return;

        }