处理tif图片

    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图片 动态添上了 其它大家自己做就好了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值