๋ฐ˜์‘ํ˜•

์†Œ๊ฐœ

MFC์—์„œ ์นด๋ฉ”๋ผ์˜ ์˜์ƒ์„ Form์— ๊ทธ๋ฆฌ๊ธฐ ์œ„ํ•ด Picture Control์„ ์ฃผ๋กœ ์‚ฌ์šฉํ•˜๋Š”๋ฐ์š”.

C#์—์„œ๋Š” ๋น„์Šทํ•˜๊ฒŒ Picture Box๊ฐ€ ์ œ๊ณต๋˜์–ด, ์ด ์ปจํŠธ๋กค์— ์นด๋ฉ”๋ผ ์˜์ƒ์„ ๊ทธ๋ฆด ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๊ทธ๋Ÿฐ๋ฐ ์ด์ƒํ•˜๊ฒŒ๋„ Picture Box(๋˜๋Š” Panel)์— ์ด๋ฏธ์ง€๋ฅผ ๊ทธ๋ฆฌ๊ฒŒ ๋˜๋ฉด Smoothing Filter๊ฐ€ ์ ์šฉ๋œ ๊ฒƒ ์ฒ˜๋Ÿผ ํ‘œํ˜„๋ฉ๋‹ˆ๋‹ค.

 

  


<์™ผ์ชฝ: ์›๋ณธ, ์˜ค๋ฅธ์ชฝ: Graphics๋กœ ๊ทธ๋ ค์ง„ ๋ชจ์Šต>

 

ํ•œ ๋ˆˆ์— ์ฐจ์ด๊ฐ€ ๋ณด์ด์ฃ ?

 Bitmap  ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•˜์—ฌ  FromFile ์„ ํ˜ธ์ถœํ•˜์—ฌ ์ด๋ฏธ์ง€๋ฅผ ๋ถˆ๋Ÿฌ์™”์„ ๋ฟ์ž…๋‹ˆ๋‹ค.

๊ทธ๋ž˜์„œ ๊ทธ๋ ค์ง€๋Š” ์ด๋ฏธ์ง€ ์ž์ฒด์˜ ๋ฐ์ดํ„ฐ๋Š” ์ •์ƒ์ด์ง€๋งŒ, ๊ทธ๋ ค์ง€๋Š” ์ž‘์—…์—์„œ ์Šค๋ฌด์‹ฑ ํ•„ํ„ฐ๊ฐ€ ์ ์šฉ๋œ ๋ชจ์Šต์œผ๋กœ ๋ณด์—ฌ์ง‘๋‹ˆ๋‹ค.

๋ณดํ†ต์€ ์›ํ˜•์ด๋‚˜ ๊ณก์„ , ์—ฃ์ง€๋ฉด์ด ๋ถ€๋“œ๋Ÿฝ๊ฒŒ ํ‘œํ˜„๋˜๊ธธ ์›ํ•˜๋Š”๋ฐ์š”.

๋จธ์‹  ๋น„์ „์—์„œ๋Š” ๊ฒฝ์šฐ์— ๋”ฐ๋ผ ๋‹ค๋ฅด๊ฒ ์ง€๋งŒ, ์ผ๋ฐ˜์ ์œผ๋กœ ์›๋ณธ ๋ฐ์ดํ„ฐ ๊ทธ๋Œ€๋กœ๋ฅผ ๋ณด์—ฌ์ค˜์•ผ ํ•ฉ๋‹ˆ๋‹ค.

๋ฌผ๋ก  ๊ทธ๋ ค์ง€๋Š” ๋ถ€๋ถ„๋งŒ ์ €๋ ‡๊ฒŒ ํ‘œํ˜„๋˜๋‹ˆ ์ƒ๊ด€ ์—†์ง€ ์•Š๊ฒ ๋ƒ๊ณ  ํ•  ์ˆ˜๋„ ์žˆ๊ฒ ์ง€๋งŒ, 

๊นŒ๋‹ค๋กœ์šด ์‚ฌ์šฉ์ž๋“ค์ด ๊ฝค ๋งŽ๊ธฐ ๋•Œ๋ฌธ์— ๊ฐœ์„  ๋ฐฉ๋ฒ•์„ ์•Œ๊ณ  ๊ณ„์‹œ๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™๋„ค์š”.

 

์ฝ”๋“œ ์˜ˆ์‹œ

๋จผ์ €, ์ฆ์ƒ์ด ๋ฐœ์ƒํ•˜๋Š” ์ฝ”๋“œ๋ฅผ ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

C#์—์„œ๋Š” ๊ทธ๋ฆฌ๋Š” ์ž‘์—…์„ ์œ„ํ•ด  Graphics  ๊ฐ์ฒด๋ฅผ ์‚ฌ์šฉํ•˜๋Š”๋ฐ, ์ด๋Š” MFC์˜ DC(Device context)๋ผ๊ณ  ์ดํ•ดํ•˜์‹œ๋ฉด ๋  ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

private void pictureBox_Paint(object sender, PaintEventArgs e)
{
	if (_Bitmap == null) //Bitmap object.
		return;
		
	e.Graphics.DrawImage(_bitmapTmp, pictureBox.ClientRectangle);
}

 

์ฝ”๋“œ๊ฐ€ ์ƒ๋‹นํžˆ ๊ฐ„๋‹จํ•˜์ฃ ?  DrawImage  API๊ฐ€ ์ „๋ถ€์ž…๋‹ˆ๋‹ค.

 

์ž, ๊ทธ๋Ÿผ ์–ด๋–ป๊ฒŒ ํ•ด๊ฒฐํ•˜๋Š”์ง€ ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

private void pictureBox_Paint(object sender, PaintEventArgs e)
{
	if (_Bitmap == null) //Bitmap object.
		return;

	e.Graphics.InterpolationMode = InterpolationMode.NearestNeighbor; //Interpolation Mode	
	e.Graphics.DrawImage(_bitmapTmp, pictureBox.ClientRectangle);
}

 

Graphics์˜ ์˜ต์…˜์œผ๋กœ  InterpolationMode ๋ฅผ  NearestNeighbor ๋กœ ๋ฐ”๊พธ๋ฉด ๋ฉ๋‹ˆ๋‹ค.

๋ณดํ†ต์€ InterpolationMode๋ฅผ ๋†’๊ฒŒ ์„ค์ •ํ•˜์—ฌ Quality ๋†’์€ ์ด๋ฏธ์ง€๋ฅผ ๊ทธ๋ฆฌ๊ฒ ์ง€๋งŒ, 

์šฐ๋ฆฌ์˜ ๋ชฉํ‘œ๋Š” ํ”ฝ์…€ ํ•˜๋‚˜ ํ•˜๋‚˜ ๊ทธ๋ฆฌ๋Š” ๊ฒƒ์ด๋ฏ€๋กœ ์˜คํžˆ๋ ค ๋‚ฎ์ถ”๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.

 

์ด ์™ธ์—๋„  CompositingMode ,  SmoothingMode  ๊ฐ™์€ ์˜ต์…˜์ด ์žˆ์œผ๋‹ˆ ์ฐธ๊ณ ํ•ด์ฃผ์„ธ์š”.

 

๋ฐ˜์‘ํ˜•