Posted
Filed under C#

[출처]- http://dragonwind.egloos.com/4849313

1. ASP.net 1.0 기준으로 web form 에서 이미지를 합쳐서 저장하기.
---------------------------------------------------------------------------
Bitmap bmap = new Bitmap(100, 100);
Graphics g = Graphics.FromImage(bmap);

System.Drawing.Image img = Bitmap.FromFile("d:\\hoonslogo.gif");
System.Drawing.Image img2 = Bitmap.FromFile("d:\\btn_individual.gif");

g.DrawImage(img, 0, 0);
g.DrawImage(img2, 50, 50);

bmap.Save("d:\\MyTest.gif", System.Drawing.Imaging.ImageFormat.Jpeg);
---------------------------------------------------------------------------

http://www.devpia.com/MAEUL/Contents/Detail.aspx?BoardID=17&MAEULNo=8&no=49092&ref=49092

2. win form 에서 이미지 합치고, picturebox 에 쓰기
---------------------------------------------------------------------------
        private void menuItem2_Click(object sender, System.EventArgs e)
        {
            //select files...
            openFileDialog1.ShowDialog();          

            if( openFileDialog1.FileNames.Length > 0 )
            {
                Bitmap canvas = new Bitmap(50,50*openFileDialog1.FileNames.Length);
                int index = 0;
                System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(canvas);
                foreach( string filename in openFileDialog1.FileNames )
                {
                    System.Drawing.Image img = System.Drawing.Image.FromFile(filename);
                    g.DrawImage(img,0,50*index,50,50);
                    index++;
                }          

                Image.GetThumbnailImageAbort myCallback = new Image.GetThumbnailImageAbort(thumbnailCallback);

                pictureBox1.Image = canvas.GetThumbnailImage(50,50*openFileDialog1.FileNames.Length,myCallback,IntPtr.Zero);

                canvas.Save("temp.jpg",System.Drawing.Imaging.ImageFormat.Jpeg);
            }          
        }

        public bool thumbnailCallback()
        {
            return false;
        }


2010/10/08 15:45 2010/10/08 15:45