Exemple #1
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_PSD();

            //ExStart:CompressingTiff

            // Load a PSD file as an image and cast it into PsdImage
            using (PsdImage psdImage = (PsdImage)Image.Load(dataDir + "layers.psd"))
            {
                // Create an instance of TiffOptions for the resultant image
                TiffOptions outputSettings = new TiffOptions(TiffExpectedFormat.Default);

                // Set BitsPerSample, Compression, Photometric mode and graycale palette
                outputSettings.BitsPerSample = new ushort[] { 4 };
                outputSettings.Compression   = TiffCompressions.Lzw;
                outputSettings.Photometric   = TiffPhotometrics.Palette;
                outputSettings.Palette       = ColorPaletteHelper.Create4BitGrayscale(true);

                psdImage.Save(dataDir + "SampleTiff_out.tiff", outputSettings);
            }


            //ExEnd:CompressingTiff
        }
        public static void Run()
        {
            Console.WriteLine("Running example CompressingTIFFImagesWithLZWAlgorithm");
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages();

            // Load an image through file path location or stream
            Image image = Image.Load(dataDir + "SampleTiff.tiff");

            // Create an instance of TiffOptions for the resultant image
            TiffOptions outputSettings = new TiffOptions(TiffExpectedFormat.Default);

            // Set BitsPerSample, Compression, Photometric mode and graycale palette
            outputSettings.BitsPerSample = new ushort[] { 4 };
            outputSettings.Compression   = TiffCompressions.Lzw;
            outputSettings.Photometric   = TiffPhotometrics.Palette;
            outputSettings.Palette       = ColorPaletteHelper.Create4BitGrayscale(false);
            image.Save(dataDir + "SampleTiff_out.tiff", outputSettings);
            Console.WriteLine("Finished example CompressingTIFFImagesWithLZWAlgorithm");
        }
        public static void Run()
        {
            // To get proper output please apply a valid Aspose.Imaging License. You can purchase full license or get 30 day temporary license from http:// Www.aspose.com/purchase/default.aspx.");
            //ExStart:CompressingTIFFImagesWithAdobeDeflateCompression
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages();

            // Load an image through file path location or stream
            Image image = Image.Load(dataDir + "SampleTiff1.tiff");

            // Create an instance of TiffOptions for the resultant image
            TiffOptions outputSettings = new TiffOptions(TiffExpectedFormat.Default);

            // Set BitsPerSample, Photometric mode & Compression mode
            outputSettings.BitsPerSample = new ushort[] { 4 };
            outputSettings.Compression   = TiffCompressions.AdobeDeflate;
            outputSettings.Photometric   = TiffPhotometrics.Palette;

            // Set graycale palette
            outputSettings.Palette = ColorPaletteHelper.Create4BitGrayscale(false);
            //ExEnd:CompressingTIFFImagesWithAdobeDeflateCompression
        }
        private void Create3DObject(object sender, EventArgs e)
        {
            try
            {
                int     nx        = System.Convert.ToInt32(tbNX.Text);
                int     ny        = System.Convert.ToInt32(tbNY.Text);
                int     nz        = System.Convert.ToInt32(tbNZ.Text);
                float   step      = System.Convert.ToSingle(tbColorIndicatorStep.Text);
                float   radius    = System.Convert.ToSingle(this.tbRadius.Text);
                int     dimenSize = nx * ny * nz;
                float   dx        = System.Convert.ToSingle(this.tbDX.Text);
                float   dy        = System.Convert.ToSingle(this.gbDY.Text);
                float   dz        = System.Convert.ToSingle(this.tbDZ.Text);
                float[] dxArray   = initArray(dimenSize, dx);
                float[] dyArray   = initArray(dimenSize, dy);
                float[] dzArray   = initArray(dimenSize, dz);
                // use CatesianGridderSource to fill HexahedronGridderElement's content.
                CatesianGridderSource source = new CatesianGridderSource()
                {
                    NX = nx, NY = ny, NZ = nz, DX = dxArray, DY = dyArray, DZ = dzArray,
                };
                source.IBlocks = GridBlockHelper.CreateBlockCoords(nx);
                source.JBlocks = GridBlockHelper.CreateBlockCoords(ny);
                source.KBlocks = GridBlockHelper.CreateBlockCoords(nz);


                //DemoPointSpriteGridderSource source = new DemoPointSpriteGridderSource() { NX = nx, NY = ny, NZ = nz, };

                ///模拟获得网格属性
                int minValue = 100;
                int maxValue = 10000;
                step = (maxValue * 1.0f - minValue * 1.0f) / 10;
                int[]   gridIndexes;
                float[] gridValues;
                //设置色标的范围
                this.scientificVisual3DControl.SetColorIndicator(minValue, maxValue, step);
                //获得每个网格上的属性值
                HexahedronGridderHelper.RandomValue(source.DimenSize, minValue, maxValue, out gridIndexes, out gridValues);
                //ColorF[] colors = new ColorF[source.DimenSize];
                //for (int i = 0; i < colors.Length; i++)
                //{
                //colors[i] = (ColorF)this.scientificVisual3DControl.MapToColor(gridValues[i]);
                //}
                UVF[] colors = new UVF[source.DimenSize];
                for (int i = 0; i < colors.Length; i++)
                {
                    colors[i] = new UVF()
                    {
                        U = (gridValues[i] - minValue) / (maxValue - minValue), V = 0.5f,
                    };
                }

                // use HexahedronGridderElement
                DateTime t0 = DateTime.Now;
                Texture2dMeshGeometry mesh = Texture2dHexahedronGridderHelper.CreateMesh(source);
                DateTime t1  = DateTime.Now;
                TimeSpan ts1 = t1 - t0;

                mesh.VertexColors = Texture2dHexahedronGridderHelper.FromColors(source, gridIndexes, colors, mesh.Visibles);
                //this.DebugMesh(mesh);

                Bitmap textureImage = ColorPaletteHelper.GenBitmap(this.scientificVisual3DControl.uiColorIndicator.Data.ColorPalette);
                Texture2dHexahedronGridderElement gridderElement = new Texture2dHexahedronGridderElement(
                    textureImage, source, this.scientificVisual3DControl.Scene.CurrentCamera);
                gridderElement.renderWireframe = false;
                //method1
                //gridderElement.Initialize(this.scientificVisual3DControl.OpenGL);

                //method2
                gridderElement.Initialize(this.scientificVisual3DControl.OpenGL, mesh);
                DateTime t2 = DateTime.Now;

                //gridderElement.SetBoundingBox(mesh.Min, mesh.Max);

                //// use PointSpriteGridderElement
                //PointSpriteMesh mesh = PointSpriteGridderElementHelper.CreateMesh(source);
                //mesh.ColorArray = PointSpriteGridderElementHelper.FromColors(source, gridIndexes, colors, mesh.VisibleArray);

                //PointSpriteGridderElement gridderElement = new PointSpriteGridderElement(source, this.scientificVisual3DControl.Scene.CurrentCamera);
                //gridderElement.Initialize(this.scientificVisual3DControl.OpenGL, mesh);
                ////DebugMesh(mesh);

                //


                gridderElement.Name = string.Format("element {0}", elementCounter++);
                this.scientificVisual3DControl.AddModelElement(gridderElement);
                DateTime t3 = DateTime.Now;
                // update ModelContainer's BoundingBox.
                BoundingBox boundingBox = this.scientificVisual3DControl.ModelContainer.BoundingBox;
                if (this.scientificVisual3DControl.ModelContainer.Children.Count > 1)
                {
                    boundingBox.Extend(mesh.Min);
                    boundingBox.Extend(mesh.Max);
                }
                else
                {
                    boundingBox.SetBounds(mesh.Min, mesh.Max);
                }
                //boundingBox.Expand();

                // update ViewType to UserView.
                this.scientificVisual3DControl.ViewType = ViewTypes.UserView;
                mesh.Dispose();

                StringBuilder msgBuilder = new StringBuilder();
                msgBuilder.AppendLine(String.Format("create mesh in {0} secs", (t1 - t0).TotalSeconds));
                msgBuilder.AppendLine(String.Format("init SceneElement in {0} secs", (t2 - t1).TotalSeconds));
                msgBuilder.AppendLine(String.Format("total load in {0} secs", (t2 - t0).TotalSeconds));
                String msg = msgBuilder.ToString();
                MessageBox.Show(msg, "Summary", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception error)
            {
                MessageBox.Show(error.ToString());
            }
        }