コード例 #1
0
        private void SaveSingleLevel(ExportModel info, TextureArray2D texture)
        {
            var width  = info.GetCropWidth();
            var height = info.GetCropHeight();

            Debug.Assert(width > 0);
            Debug.Assert(height > 0);

            var data = texture.GetData(info.Layer, info.Mipmap, info.TexFormat.Format,
                                       info.UseCropping, info.CropStartX, info.CropStartY, ref width, ref height,
                                       models.GlData.ExportShader);

            if (data == null)
            {
                throw new Exception("error retrieving image from gpu");
            }

            var numComponents = 0;

            numComponents = TextureArray2D.GetPixelFormatCount(info.TexFormat.Format.Format);

            switch (info.FileType)
            {
            case ExportModel.FileFormat.Png:
                ImageLoader.SavePng(info.Filename, width, height, numComponents, data);
                break;

            case ExportModel.FileFormat.Bmp:
                ImageLoader.SaveBmp(info.Filename, width, height, numComponents, data);
                break;

            case ExportModel.FileFormat.Hdr:
                ImageLoader.SaveHdr(info.Filename, width, height, numComponents, data);
                break;

            case ExportModel.FileFormat.Pfm:
                ImageLoader.SavePfm(info.Filename, width, height, numComponents, data);
                break;

            case ExportModel.FileFormat.Jpg:
                ImageLoader.SaveJpg(info.Filename, width, height, numComponents, data, info.Quality);
                break;
            }
        }