如何在asp.net中分割多带图像 [英] How to split a Multistrip image in asp.net
本文介绍了如何在asp.net中分割多带图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在同一文件中有一个包含三个子图像的图像,它们均为jpg格式.
我想在ASP.net应用程序中显示,所以请建议我显示消息的最佳方法.
或如何将原始图像拆分为三个单独的图像.
谢谢,
Srikanth
Hi,
I had a image with three sub images in the same file which is in jpg format.
I want to show in ASP.net application, so Please suggest me the best way to show the message..
or How can I split the original image to three separate images.
Thanks,
Srikanth
推荐答案
using (Bitmap bmp = new Bitmap(Server.MapPath("test.jpg")))
{
// Get pages in bitmap
int frames = bmp.GetFrameCount(System.Drawing.Imaging.FrameDimension.Page);
//Loop through the images and save in a location
for (int i = 0; i < frames; i++)
{
bmp.SelectActiveFrame(System.Drawing.Imaging.FrameDimension.Page, i);
using (Bitmap bmp2 = new Bitmap(bmp.Width, bmp.Height))
{
bmp2.Palette = bmp.Palette;
bmp2.SetResolution(bmp.HorizontalResolution, bmp.VerticalResolution);
// create graphics object for new bitmap
using (Graphics g = Graphics.FromImage(bmp2))
{ // copy current page into new bitmap
g.DrawImageUnscaled(bmp, 0, 0);
// do whatever you migth to do ...
}
bmp2.Save(Server.MapPath("") + @"\bmp" + i +".jpg");
}
}
}
这篇关于如何在asp.net中分割多带图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文