Click here to Skip to main content
15,905,144 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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
Posted
Comments
Sergey Alexandrovich Kryukov 20-Jul-11 3:35am    
Not clear. It needs exact requirements, pre-conditions, all the detail.
--SA
Keith Barrow 20-Jul-11 4:32am    
What do you mean by "sub images"? I also do not understand what message you want to show, please clarify you question.

1 solution

C#
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");
                   }
               }
           }


 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900