陋室铭
永远也不要停下学习的脚步(大道至简至易)

posts - 2169,comments - 570,views - 413万

    protected void ManageTif()
    {
        //分割Tif图片为多个Gif图片
        string TruePath = Server.MapPath("../Images/www.tif");
        System.Drawing.Image img = System.Drawing.Image.FromFile(TruePath);
        Guid guid = (Guid)img.FrameDimensionsList.GetValue(0);
        FrameDimension dimension = new FrameDimension(guid);
        int totalPage = img.GetFrameCount(dimension);

        this.statusBar1.Text = "共" + totalPage + "页";

        for (int i = 0; i < totalPage; i++)
        {
            img.SelectActiveFrame(dimension, i);
            //直接用image存(经测试转换的不清晰)
            //img.Save(Server.MapPath("../Images/") + i + ".gif", System.Drawing.Imaging.ImageFormat.Gif);

            //使用内存流(经测试效果应该是最好的)
            //System.IO.MemoryStream ms = new System.IO.MemoryStream();
            //img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
            //Response.ClearContent();
            //Response.ContentType = "image/Jpeg";
            //Response.BinaryWrite(ms.ToArray());

            //使用文件流(经测试效果中等,我现在的选择)
            Bitmap newBmp = new Bitmap(img.Width, img.Height, PixelFormat.Format24bppRgb);
            newBmp.Save(Server.MapPath("../Images/")+ i + ".gif", ImageFormat.Jpeg);
            System.IO.FileStream fs = new System.IO.FileStream(Server.MapPath("../Images/") + i + ".gif", System.IO.FileMode.Open);
            img.Save(fs, System.Drawing.Imaging.ImageFormat.Jpeg);
            //动态的添上
            Table tblParent = new Table();
            TableRow row = new TableRow();
            tblParent.Rows.Add(row);
            TableCell cell = new TableCell();
            cell.Width = Unit.Percentage(30);
            row.Cells.Add(cell);
            System.Web.UI.WebControls.Image ImageTmp = new System.Web.UI.WebControls.Image();
            ImageTmp.ID = "ImageTmp" + "i";
            ImageTmp.ImageUrl = "../Images/" + i + ".gif";
            row.Cells[0].Controls.Add(ImageTmp);
            form1.Controls.Add(tblParent);
        }
    }


Image1.ImageUrl = "../Images/" + i + ".gif";是我懒了 只做了一个显示 正常的话 应该动态生成分成的gif图片数
还要建一个这些图片的索引 说明这些图片属于一个tif图片 动态添上了 其它大家自己做就好了

posted on   宏宇  阅读(1687)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 25岁的心里话
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
< 2007年7月 >
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31 1 2 3 4
5 6 7 8 9 10 11

点击右上角即可分享
微信分享提示