µðÄ«·Î ÂïÀº »çÁø¿¡ ÃÔ¿µ ³¯Â¥ ±×¸®±â

±× µ¿¾È ÂïÀº »çÁøÀ» ÀÎÈ­ÇÏ·Á´Âµ¥ ÃÔ¿µ ³¯Â¥°¡ »çÁø¿¡ Ç¥½ÃµÇÀÖÁö ¾Ê¾Æ¼­ ¾Ù¹ü¿¡ Á¤¸®ÇØ ³õ±â°¡ ´ë·« ³­°¨Çß´Ù. ±×·¡¼­ ÁÖ¸»¿¡ ¸î½Ã°£ ³»¼­ ´ÙÀ½°ú °°Àº Äڵ带 ¸¸µé°Ô µÇ¾ú´Ù.

¾Æ·¡ ¸Þ¼Òµå´Â jpg À̹ÌÁöÀÇ ¼Ó¼ºÁß ÃÔ¿µÀÏ ¼Ó¼ºÀÇ °ªÀ» ÀÐ¾î »çÁø ÁÂÃø »ó´Ü¿¡ ±×¸°ÈÄ ÀúÀåÇÑ´Ù.

public static void putDateOnPicture(string srcFile, string destFile)
{
	const int PropertyTagDateTime = 0x132;

	Image img = Image.FromFile(srcFile);

	string dateTaken = "";
	foreach(PropertyItem prop in img.PropertyItems)
	{
		switch(prop.Id)
		{
			case PropertyTagDateTime:
				// convert prop value to string
				StringBuilder sb = new StringBuilder();
				char[] propVal = new char[prop.Len];
				Encoding.ASCII.GetChars(prop.Value, 0,
					prop.Value.Length - 1, propVal, 0);
				sb.Append(propVal);
				dateTaken = sb.ToString();
				break;

			default:
				break;
		}

		if(dateTaken.Length > 0)
		{
			Graphics g = Graphics.FromImage(img);
			Font font = new Font("Arial", 20);
			SolidBrush bgBrush = new SolidBrush(Color.Black);
			SolidBrush brush = new SolidBrush(Color.White);

			// draw black box
			SizeF box = g.MeasureString(dateTaken, font);
			g.FillRectangle(bgBrush, 0, 0, box.Width, box.Height);
			// draw date string
			g.DrawString(dateTaken, font, brush, new PointF(0F, 0F));
			// save
			img.Save(destFile);

			dateTaken = "";
			break;				// exit for loop
		}
	}
}

update:

img.Save(destFile);

ºÎºÐ¿¡¼­ GDI+ ¿¡·¯°¡ ¹ß»ýÇÏ´õ±º¿ä.

¸ðµç ÆÄÀÏ¿¡ ¹ß»ýÇÏ´Â °ÍÀº ¾Æ´Ñµ¥¿ä…

¿øÀÎ ±Ô¸íÀ» ¸øÇß½À´Ï´Ù.

¾Æ½Ã´Â ºÐ Á» ¾Ë·ÁÁÖ¼¼¿ä :)

2004-05-23 4:05 AM
permalink

Ä¿¸ÇÆ®¿Í Æ®·¢¹é rss (0)

Æ®·¢¹é ÁÖ¼Ò: http://codian.net/wp/archives/104/trackback/

Ä¿¸ÇÆ® ÀÛ¼º