[자답 해결] GDI+ DrawCurve 작동이 잘 안되네요.

cppig1995의 이미지

정적(static) 멤버 함수인 Drw2Shape::DrawCurve에서
전역(global) 함수인 CreateAppropriateBrush를 호출하며,
멤버 함수인 Drw2Shape::Draw는 sh->Type이 CurveTool일 때
Drw2Shape::DrawCurve(G, this)를 호출합니다.
그리고 CDrawing2View의 OnDraw에서 sh.Draw()를 호출합니다.
그런데 화면에 표시되는게 없네요. 저도 뭐가 잘못됐는지 모르겠습니다.
GDI+ 프로그래밍은 처음이라...

고수님들 도움 부탁드립니다.

Status Drw2Shape::DrawCurve(Graphics &G, const Drw2Shape *sh)
{
	Brush *pBL;
	Status CabSt = CreateAppropriateBrush(&pBL, NULL, sh);
	if(CabSt != Ok) return CabSt;
	Pen P(pBL, sh->LineWidth);
	if(P.GetLastStatus() != Ok) return P.GetLastStatus();
	G.DrawCurve(&P, sh->Points, sh->VarDataLen / sizeof(Point), sh->tension);
	delete pBL;
	return Ok;
}

Status CreateAppropriateBrush(Brush **pBL, Brush **pBF, const Drw2Shape *sh)
{
	try
	{
		if(pBL)
		{
			switch(sh->WhichBrush & LineMask)
			{
			case LineSolidBrush:
				*pBL = new SolidBrush(sh->LineColor1);
				break;
			case LineGradientBrush:
				*pBL = new LinearGradientBrush(sh->rect,
					sh->LineColor1, sh->LineColor2, sh->LineGradAngle);
				break;
			case LineHatchBrush:
				*pBL = new HatchBrush(sh->LineHatchStyle, sh->LineColor1, sh->LineColor2);
				break;
			}
		}
		if(pBF)
		{
			switch(sh->WhichBrush & FillMask)
			{
			case FillSolidBrush:
				*pBF = new SolidBrush(sh->FillColor1);
				break;
			case FillGradientBrush:
				*pBF = new LinearGradientBrush(sh->rect,
					sh->FillColor1, sh->FillColor2, sh->FillGradAngle);
				break;
			case FillHatchBrush:
				*pBF = new HatchBrush(sh->FillHatchStyle, sh->FillColor1, sh->FillColor2);
				break;
			}
		}
	}
	catch(...)
	{
		return OutOfMemory;
	}
	return Ok;
}

void CDrawing2View::OnDraw(CDC* pDC)
{
	CDrawing2Doc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	if (!pDoc) return;
 
	Graphics G(pDC->m_hDC);
	Drw2Shape sh;
	Point pts[] = {Point(25, 25), Point(35, 35), Point(45, 15), Point(50, 70), Point(5, 85), Point(35, 25)};
	sh.Type = CurveTool;
	sh.LineColor1 = Color(255, 255, 153, 0);
	sh.LineColor2 = Color(255, 0, 153, 0);
	sh.WhichBrush = LineGradientBrush;
	sh.VarDataLen = sizeof(pts);
	sh.Points = pts;
	sh.LineHatchStyle = HatchStyleWeave;
	sh.tension = 0.7;
	sh.LineWidth = 30;
	sh.Draw(G);
	Invalidate();
}

cppig1995의 이미지

CreateAppropriateBrush에서 BrushStyle에 따라 브러시를 생성하게 만들어 놓고,
BrushStyle을 선에 선형 그래디언트 브러시를 사용하게(LineGradientBrush) 설정한 상태에서
해치스타일을 지정했네요;;;
이제 더블버퍼링이 필요해... 엄청난 깜빡거림



[cppig1995@localhost cppig1995]$ make
make: *** No targets specified and no makefile found. 멈춤.
[cppig1995@localhost cppig1995]$ make idea
make: *** 목표 'idea'를 만들 규칙이 없음. 멈춤.

Real programmers /* don't */ comment their code.
If it was hard to write, it should be /* hard to */ read.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.