当前位置: 首页>>代码示例>>C#>>正文


C# Tiff.ReadRGBATile方法代码示例

本文整理汇总了C#中BitMiracle.LibTiff.Classic.Tiff.ReadRGBATile方法的典型用法代码示例。如果您正苦于以下问题:C# Tiff.ReadRGBATile方法的具体用法?C# Tiff.ReadRGBATile怎么用?C# Tiff.ReadRGBATile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BitMiracle.LibTiff.Classic.Tiff的用法示例。


在下文中一共展示了Tiff.ReadRGBATile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: displayTiff

        //Displays the specified tiff in the picturebox
        private bool displayTiff(string tiffname)
        {
            int[] raster = new int[tileSize];
            try
            {
                using (image = Tiff.Open(tiffname, "r"))
                {
                    //loop through each tile column
                    for (int g = 0; g < bmp.Width / tileWidth + 1; g++)
                    {
                        //loop through each tile in that column
                        for (int h = 0; h < bmp.Height / tileHeight + 1; h++)
                        {
                            image.ReadRGBATile(tileWidth * g, tileHeight * h, raster);
                            //loop through each pixel column
                            for (int i = 0; i < tileWidth; i++)
                            {
                                //loop through each pixel in that column
                                for (int j = 0; j < tileHeight; j++)
                                {

                                    if ((g * tileWidth + i < bmp.Width) && (h * tileHeight + j < bmp.Height))
                                    {

                                        bmp.SetPixel(g * tileWidth + i, h * tileHeight + j, getSample(i, j, raster, tileWidth, tileHeight));

                                    }
                                }
                            }
                        }
                    }
                    pictureBox1.Image = bmp;
                    return true;
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                return false;
            }
        }
开发者ID:stereoa,项目名称:condorsubmitgui,代码行数:42,代码来源:RadiancePreview.cs

示例2: cvt_by_tile

        static bool cvt_by_tile(Tiff inImage, Tiff outImage, int width, int height)
        {
            int tile_width = 0;
            int tile_height = 0;

            FieldValue[] result = inImage.GetField(TiffTag.TILEWIDTH);
            if (result != null)
            {
                tile_width = result[0].ToInt();

                result = inImage.GetField(TiffTag.TILELENGTH);
                if (result != null)
                    tile_height = result[0].ToInt();
            }

            if (result == null)
            {
                Tiff.Error(inImage.FileName(), "Source image not tiled");
                return false;
            }

            outImage.SetField(TiffTag.TILEWIDTH, tile_width);
            outImage.SetField(TiffTag.TILELENGTH, tile_height);

            // Allocate tile buffer
            int raster_size = multiply(tile_width, tile_height);
            int rasterByteSize = multiply(raster_size, sizeof(int));
            if (raster_size == 0 || rasterByteSize == 0)
            {
                Tiff.Error(inImage.FileName(),
                    "Can't allocate buffer for raster of size {0}x{1}", tile_width, tile_height);
                return false;
            }

            int[] raster = new int[raster_size];
            byte[] rasterBytes = new byte[rasterByteSize];

            // Allocate a scanline buffer for swapping during the vertical mirroring pass.
            // (Request can't overflow given prior checks.)
            int[] wrk_line = new int[tile_width];

            // Loop over the tiles.
            for (int row = 0; row < height; row += tile_height)
            {
                for (int col = 0; col < width; col += tile_width)
                {
                    // Read the tile into an RGBA array
                    if (!inImage.ReadRGBATile(col, row, raster))
                        return false;

                    // For some reason the ReadRGBATile() function chooses the lower left corner
                    // as the origin. Vertically mirror scanlines.
                    for (int i_row = 0; i_row < tile_height / 2; i_row++)
                    {
                        int topIndex = tile_width * i_row * sizeof(int);
                        int bottomIndex = tile_width * (tile_height - i_row - 1) * sizeof(int);

                        Buffer.BlockCopy(raster, topIndex, wrk_line, 0, tile_width * sizeof(int));
                        Buffer.BlockCopy(raster, bottomIndex, raster, topIndex, tile_width * sizeof(int));
                        Buffer.BlockCopy(wrk_line, 0, raster, bottomIndex, tile_width * sizeof(int));
                    }

                    // Write out the result in a tile.
                    int tile = outImage.ComputeTile(col, row, 0, 0);
                    Buffer.BlockCopy(raster, 0, rasterBytes, 0, rasterByteSize);
                    if (outImage.WriteEncodedTile(tile, rasterBytes, rasterByteSize) == -1)
                        return false;
                }
            }

            return true;
        }
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:72,代码来源:Converter.cs


注:本文中的BitMiracle.LibTiff.Classic.Tiff.ReadRGBATile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。